X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/286e2db69c9c121e1285b3f70b36aaef584557a9..f9ee64b1356530b7f5c957d250d2a1dcbef60f60:/wxPython/tools/img2py.py diff --git a/wxPython/tools/img2py.py b/wxPython/tools/img2py.py index 6af6409fa2..863de24d42 100644 --- a/wxPython/tools/img2py.py +++ b/wxPython/tools/img2py.py @@ -28,6 +28,8 @@ Options: -u Don't use compression. Leaves the data uncompressed. + -i Also output a function to return the image as a wxIcon. + """ @@ -38,7 +40,7 @@ import img2xpm def crunch_data(data, compressed): - # convert the lines to a Python list, pickle it and compress the result. + # convert the lines to a Python list, pickle it and optionally compress the result. lines = [] for line in data: if line[0] == "\"": @@ -111,9 +113,10 @@ def main(args): compressed = 1 maskClr = None imgName = "" + icon = 0 try: - opts, fileArgs = getopt.getopt(args, "aun:m:") + opts, fileArgs = getopt.getopt(args, "auin:m:") except getopt.GetoptError: print __doc__ return @@ -127,6 +130,8 @@ def main(args): imgName = val elif opt == "-m": maskClr = val + elif opt == "-i": + icon = 1 if len(fileArgs) != 2: print __doc__ @@ -154,6 +159,8 @@ def main(args): if not append: out.write("# This file was generated by %s\n#\n" % sys.argv[0]) out.write("from wxPython.wx import wxBitmapFromXPMData, wxImageFromBitmap\n") + if icon: + out.write("from wxPython.wx import wxIconFromXPMData\n") if compressed: out.write("import cPickle, zlib\n\n\n") else: @@ -174,6 +181,11 @@ def main(args): "def get%sImage():\n" " return wxImageFromBitmap(get%sBitmap())\n\n" % tuple([imgName] * 4)) + if icon: + out.write("def get%sIcon():\n" + " return wxIconFromXPMData(get%sData())\n\n" + % tuple([imgName] * 2)) + if imgName: n_msg = ' using "%s"' % imgName