-u Don't use compression. Leaves the data uncompressed.
+ -i Also output a function to return the image as a wxIcon.
+
"""
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] == "\"":
c = i = 0
word = ""
octdigits = "01234567"
+ hexdigits = "0123456789abcdef"
while i < len(data):
if data[i] != "\\":
word = data[i]
break
word = data[i:i+n]
i = i + n
+ elif data[i+1] == 'x':
+ for n in range(2, 5):
+ if data[i+n] not in hexdigits:
+ break
+ word = data[i:i+n]
+ i = i + n
else:
word = data[i:i+2]
i = i + 2
+
l = len(word)
if c + l >= 78-1:
fp.write("\\\n")
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
imgName = val
elif opt == "-m":
maskClr = val
+ elif opt == "-i":
+ icon = 1
if len(fileArgs) != 2:
print __doc__
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:
"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