Changed the img2py tool to use PNG instead of XPM for embedding image

data in Python source code, and the generated code now uses streams to
convert the image data to wxImage, wxBitmap, or wxIcon.

A few other changes to match recent additions to CVS.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14416 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2002-02-26 22:35:10 +00:00
parent c2ff68d3fd
commit afb810d936
19 changed files with 3675 additions and 1986 deletions

View File

@ -18,6 +18,9 @@ Finished wrapping and providing typemaps for wxInputStream and also
added the stream ctor and other methods for wxImage so images can now
be loaded from any Python "file-like" object.
Changed the img2py tool to use PNG instead of XPM for embedding image
data in Python source code, and the generated code now uses streams to
convert the image data to wxImage, wxBitmap, or wxIcon.

View File

@ -113,14 +113,7 @@ class wxPythonDemo(wxFrame):
self.cwd = os.getcwd()
self.curOverview = ""
if 1:
icon = wxIconFromXPMData(images.getMondrianData())
else:
# another way to do it
bmp = images.getMondrianBitmap()
icon = wxEmptyIcon()
icon.CopyFromBitmap(bmp)
icon = images.getMondrianIcon()
self.SetIcon(icon)
if wxPlatform == '__WXMSW__':
@ -192,8 +185,8 @@ class wxPythonDemo(wxFrame):
self.tree = wxTreeCtrl(splitter, tID,
style=wxTR_HAS_BUTTONS |
wxTR_EDIT_LABELS |
wxTR_HAS_VARIABLE_ROW_HEIGHT |
wxSUNKEN_BORDER)
wxTR_HAS_VARIABLE_ROW_HEIGHT)
#self.tree.SetBackgroundColour(wxNamedColour("Pink"))
root = self.tree.AddRoot("Overview")
firstChild = None
@ -256,12 +249,13 @@ class wxPythonDemo(wxFrame):
# add the windows to the splitter and split it.
splitter2.SplitHorizontally(self.nb, self.log)
splitter.SplitVertically(self.tree, splitter2)
splitter.SetSashPosition(180, true)
splitter.SetMinimumPaneSize(20)
splitter2.SetSashPosition(450, true)
splitter2.SetMinimumPaneSize(20)
splitter.SplitVertically(self.tree, splitter2)
splitter.SetSashPosition(180, true)
splitter.SetMinimumPaneSize(20)
# select initial items

View File

Before

Width:  |  Height:  |  Size: 255 B

After

Width:  |  Height:  |  Size: 255 B

View File

Before

Width:  |  Height:  |  Size: 4.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -13,49 +13,51 @@ import img2py
command_lines = [
" -n Mondrian bmp_source/mondrian.ico images.py",
" -u -i -n Mondrian bmp_source/mondrian.ico images.py",
"-a -n _10s_ bmp_source/10s.gif images.py",
"-a -n _01c_ bmp_source/01c.gif images.py",
"-a -n _12h_ bmp_source/12h.gif images.py",
"-a -n _13d_ bmp_source/13d.gif images.py",
"-a -n Background bmp_source/backgrnd.png images.py",
"-a -n TestStar -m #FFFFFF bmp_source/teststar.png images.py",
"-a -n TestStar2 bmp_source/teststar.png images.py",
"-a -n TestMask bmp_source/testmask.bmp images.py",
"-a -u -n _10s_ bmp_source/10s.gif images.py",
"-a -u -n _01c_ bmp_source/01c.gif images.py",
"-a -u -n _12h_ bmp_source/12h.gif images.py",
"-a -u -n _13d_ bmp_source/13d.gif images.py",
"-a -u -n Background bmp_source/backgrnd.png images.py",
"-a -u -n TestStar -m #FFFFFF bmp_source/teststar.png images.py",
"-a -u -n TestStar2 bmp_source/teststar.png images.py",
"-a -u -n TestMask bmp_source/testmask.bmp images.py",
"-a -n Test2 bmp_source/test2.bmp images.py",
# "-a -n Robin bmp_source/robin.jpg images.py",
"-a -u -n Test2 bmp_source/test2.bmp images.py",
"-a -u -n Robin bmp_source/robin.jpg images.py",
"-a -n Bulb1 bmp_source/lb1.bmp images.py",
"-a -n Bulb2 bmp_source/lb2.bmp images.py",
"-a -u -n Bulb1 bmp_source/lb1.bmp images.py",
"-a -u -n Bulb2 bmp_source/lb2.bmp images.py",
"-a -n Calendar bmp_source/Calend.bmp images.py",
"-a -n DbDec bmp_source/DbDec.bmp images.py",
"-a -n Dec bmp_source/Dec.bmp images.py",
"-a -n Pt bmp_source/Pt.bmp images.py",
"-a -n DbInc bmp_source/DbInc.bmp images.py",
"-a -n Inc bmp_source/Inc.bmp images.py",
"-a -u -n Calendar bmp_source/Calend.bmp images.py",
"-a -u -n DbDec bmp_source/DbDec.bmp images.py",
"-a -u -n Dec bmp_source/Dec.bmp images.py",
"-a -u -n Pt bmp_source/Pt.bmp images.py",
"-a -u -n DbInc bmp_source/DbInc.bmp images.py",
"-a -u -n Inc bmp_source/Inc.bmp images.py",
"-a -n New -m #C0C0C0 bmp_source/new.bmp images.py",
"-a -n Open -m #C0C0C0 bmp_source/open.bmp images.py",
"-a -n Copy -m #C0C0C0 bmp_source/copy.bmp images.py",
"-a -n Paste -m #C0C0C0 bmp_source/paste.bmp images.py",
"-a -n Tog1 -m #C0C0C0 bmp_source/tog1.bmp images.py",
"-a -n Tog2 -m #C0C0C0 bmp_source/tog2.bmp images.py",
"-a -u -n New -m #C0C0C0 bmp_source/new.bmp images.py",
"-a -u -n Open -m #C0C0C0 bmp_source/open.bmp images.py",
"-a -u -n Copy -m #C0C0C0 bmp_source/copy.bmp images.py",
"-a -u -n Paste -m #C0C0C0 bmp_source/paste.bmp images.py",
"-a -u -n Tog1 -m #C0C0C0 bmp_source/tog1.bmp images.py",
"-a -u -n Tog2 -m #C0C0C0 bmp_source/tog2.bmp images.py",
"-a -n Smiles -m #FFFFFF bmp_source/smiles2.bmp images.py",
"-a -u -n Smiles -m #FFFFFF bmp_source/smiles2.bmp images.py",
"-a -n GridBG bmp_source/GridBG.gif images.py",
"-a -u -n GridBG bmp_source/GridBG.gif images.py",
"-a -n SmallUpArrow -m #0000FF bmp_source/sm_up.bmp images.py",
"-a -n SmallDnArrow -m #0000FF bmp_source/sm_down.bmp images.py",
"-a -u -n SmallUpArrow -m #0000FF bmp_source/sm_up.bmp images.py",
"-a -u -n SmallDnArrow -m #0000FF bmp_source/sm_down.bmp images.py",
"-a -n Folder1 -m #FFFFFF bmp_source/folder1.bmp images.py",
"-a -n Folder2 -m #FFFFFF bmp_source/folder2.bmp images.py",
"-a -n Folder3 -m #FFFFFF bmp_source/folder3.bmp images.py",
"-a -n File1 -m #FFFFFF bmp_source/file1.bmp images.py",
"-a -n File2 -m #FFFFFF bmp_source/file2.bmp images.py",
"-a -u -n Folder1 -m #FFFFFF bmp_source/folder1.bmp images.py",
"-a -u -n Folder2 -m #FFFFFF bmp_source/folder2.bmp images.py",
"-a -u -n Folder3 -m #FFFFFF bmp_source/folder3.bmp images.py",
"-a -u -n File1 -m #FFFFFF bmp_source/file1.bmp images.py",
"-a -u -n File2 -m #FFFFFF bmp_source/file2.bmp images.py",
"-a -u -n NoIcon bmp_source/noicon.png images.py"
]

File diff suppressed because it is too large Load Diff

View File

@ -165,9 +165,10 @@ overview = """\
import mimetypes_wdr
import images
def MyBitmapsFunc( index ):
return wxImage( opj("bitmaps/noicon.png"), wxBITMAP_TYPE_PNG ).ConvertToBitmap()
return images.getNoIconBitmap()
mimetypes_wdr.MyBitmapsFunc = MyBitmapsFunc

View File

@ -21,11 +21,7 @@ class TestPanel(wxPanel):
wxStaticBitmap(self, -1, bmp, wxPoint(80, 50),
wxSize(bmp.GetWidth(), bmp.GetHeight()))
# This one doesn't convert to the embedded format very well,
# (lots of colors so it explodes in size and takes a noticable
# amount of time to convert back to a bitmap.) So we'll just
# do it the old way
bmp = wxBitmap(opj('bitmaps/robin.jpg'), wxBITMAP_TYPE_JPEG)
bmp = images.getRobinBitmap()
wxStaticBitmap(self, -1, bmp, (80, 150))
wxStaticText(self, -1, "Hey, if Ousterhout can do it, so can I.",

View File

@ -995,10 +995,9 @@ enum wxEventType {
wxEVT_ERASE_BACKGROUND,
wxEVT_NC_PAINT,
wxEVT_PAINT_ICON,
wxEVT_MENU_CHAR,
wxEVT_MENU_INIT,
wxEVT_MENU_OPEN,
wxEVT_MENU_CLOSE,
wxEVT_MENU_HIGHLIGHT,
wxEVT_POPUP_MENU_INIT,
wxEVT_SYS_COLOUR_CHANGED,
wxEVT_DISPLAY_CHANGED,
wxEVT_SETTING_CHANGED,

View File

@ -62,6 +62,12 @@ def EVT_KEY_DOWN(win, func):
def EVT_KEY_UP(win, func):
win.Connect(-1, -1, wxEVT_KEY_UP, func)
def EVT_MENU_OPEN(win, func):
win.Connect(-1, -1, wxEVT_MENU_OPEN, func)
def EVT_MENU_CLOSE(win, func):
win.Connect(-1, -1, wxEVT_MENU_CLOSE, func)
def EVT_MENU_HIGHLIGHT(win, id, func):
win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func)

View File

@ -302,6 +302,7 @@ class wxMenuEvent: public wxEvent {
public:
wxMenuEvent(WXTYPE id = 0, int id = 0);
int GetMenuId();
bool IsPopup();
};
//---------------------------------------------------------------------------

View File

@ -4734,6 +4734,34 @@ static PyObject *_wrap_wxMenuEvent_GetMenuId(PyObject *self, PyObject *args, PyO
return _resultobj;
}
#define wxMenuEvent_IsPopup(_swigobj) (_swigobj->IsPopup())
static PyObject *_wrap_wxMenuEvent_IsPopup(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
bool _result;
wxMenuEvent * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxMenuEvent_IsPopup",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxMenuEvent_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxMenuEvent_IsPopup. Expected _wxMenuEvent_p.");
return NULL;
}
}
{
PyThreadState* __tstate = wxPyBeginAllowThreads();
_result = (bool )wxMenuEvent_IsPopup(_arg0);
wxPyEndAllowThreads(__tstate);
if (PyErr_Occurred()) return NULL;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
static void *SwigwxShowEventTowxEvent(void *ptr) {
wxShowEvent *src;
wxEvent *dest;
@ -7184,6 +7212,7 @@ static PyMethodDef eventscMethods[] = {
{ "wxShowEvent_GetShow", (PyCFunction) _wrap_wxShowEvent_GetShow, METH_VARARGS | METH_KEYWORDS },
{ "wxShowEvent_SetShow", (PyCFunction) _wrap_wxShowEvent_SetShow, METH_VARARGS | METH_KEYWORDS },
{ "new_wxShowEvent", (PyCFunction) _wrap_new_wxShowEvent, METH_VARARGS | METH_KEYWORDS },
{ "wxMenuEvent_IsPopup", (PyCFunction) _wrap_wxMenuEvent_IsPopup, METH_VARARGS | METH_KEYWORDS },
{ "wxMenuEvent_GetMenuId", (PyCFunction) _wrap_wxMenuEvent_GetMenuId, METH_VARARGS | METH_KEYWORDS },
{ "new_wxMenuEvent", (PyCFunction) _wrap_new_wxMenuEvent, METH_VARARGS | METH_KEYWORDS },
{ "new_wxInitDialogEvent", (PyCFunction) _wrap_new_wxInitDialogEvent, METH_VARARGS | METH_KEYWORDS },

View File

@ -629,6 +629,9 @@ class wxMenuEventPtr(wxEventPtr):
def GetMenuId(self, *_args, **_kwargs):
val = apply(eventsc.wxMenuEvent_GetMenuId,(self,) + _args, _kwargs)
return val
def IsPopup(self, *_args, **_kwargs):
val = apply(eventsc.wxMenuEvent_IsPopup,(self,) + _args, _kwargs)
return val
def __repr__(self):
return "<C wxMenuEvent instance at %s>" % (self.this,)
class wxMenuEvent(wxMenuEventPtr):

View File

@ -2622,10 +2622,9 @@ SWIGEXPORT(void) initwxc() {
PyDict_SetItemString(d,"wxEVT_ERASE_BACKGROUND", PyInt_FromLong((long) wxEVT_ERASE_BACKGROUND));
PyDict_SetItemString(d,"wxEVT_NC_PAINT", PyInt_FromLong((long) wxEVT_NC_PAINT));
PyDict_SetItemString(d,"wxEVT_PAINT_ICON", PyInt_FromLong((long) wxEVT_PAINT_ICON));
PyDict_SetItemString(d,"wxEVT_MENU_CHAR", PyInt_FromLong((long) wxEVT_MENU_CHAR));
PyDict_SetItemString(d,"wxEVT_MENU_INIT", PyInt_FromLong((long) wxEVT_MENU_INIT));
PyDict_SetItemString(d,"wxEVT_MENU_OPEN", PyInt_FromLong((long) wxEVT_MENU_OPEN));
PyDict_SetItemString(d,"wxEVT_MENU_CLOSE", PyInt_FromLong((long) wxEVT_MENU_CLOSE));
PyDict_SetItemString(d,"wxEVT_MENU_HIGHLIGHT", PyInt_FromLong((long) wxEVT_MENU_HIGHLIGHT));
PyDict_SetItemString(d,"wxEVT_POPUP_MENU_INIT", PyInt_FromLong((long) wxEVT_POPUP_MENU_INIT));
PyDict_SetItemString(d,"wxEVT_SYS_COLOUR_CHANGED", PyInt_FromLong((long) wxEVT_SYS_COLOUR_CHANGED));
PyDict_SetItemString(d,"wxEVT_DISPLAY_CHANGED", PyInt_FromLong((long) wxEVT_DISPLAY_CHANGED));
PyDict_SetItemString(d,"wxEVT_SETTING_CHANGED", PyInt_FromLong((long) wxEVT_SETTING_CHANGED));

View File

@ -854,10 +854,9 @@ wxEVT_PAINT = wxc.wxEVT_PAINT
wxEVT_ERASE_BACKGROUND = wxc.wxEVT_ERASE_BACKGROUND
wxEVT_NC_PAINT = wxc.wxEVT_NC_PAINT
wxEVT_PAINT_ICON = wxc.wxEVT_PAINT_ICON
wxEVT_MENU_CHAR = wxc.wxEVT_MENU_CHAR
wxEVT_MENU_INIT = wxc.wxEVT_MENU_INIT
wxEVT_MENU_OPEN = wxc.wxEVT_MENU_OPEN
wxEVT_MENU_CLOSE = wxc.wxEVT_MENU_CLOSE
wxEVT_MENU_HIGHLIGHT = wxc.wxEVT_MENU_HIGHLIGHT
wxEVT_POPUP_MENU_INIT = wxc.wxEVT_POPUP_MENU_INIT
wxEVT_SYS_COLOUR_CHANGED = wxc.wxEVT_SYS_COLOUR_CHANGED
wxEVT_DISPLAY_CHANGED = wxc.wxEVT_DISPLAY_CHANGED
wxEVT_SETTING_CHANGED = wxc.wxEVT_SETTING_CHANGED
@ -955,6 +954,12 @@ def EVT_KEY_DOWN(win, func):
def EVT_KEY_UP(win, func):
win.Connect(-1, -1, wxEVT_KEY_UP, func)
def EVT_MENU_OPEN(win, func):
win.Connect(-1, -1, wxEVT_MENU_OPEN, func)
def EVT_MENU_CLOSE(win, func):
win.Connect(-1, -1, wxEVT_MENU_CLOSE, func)
def EVT_MENU_HIGHLIGHT(win, id, func):
win.Connect(id, -1, wxEVT_MENU_HIGHLIGHT, func)

76
wxPython/tools/img2img.py Normal file
View File

@ -0,0 +1,76 @@
"""
Common routines for the image converter utilities.
"""
import sys, os, glob, getopt, string
from wxPython.wx import *
wxInitAllImageHandlers()
def convert(file, maskClr, outputDir, outputName, outType, outExt):
if string.lower(os.path.splitext(file)[1]) == ".ico":
icon = wxIcon(file, wxBITMAP_TYPE_ICO)
img = wxBitmapFromIcon(icon)
else:
img = wxBitmap(file, wxBITMAP_TYPE_ANY)
if not img.Ok():
return 0, file + " failed to load!"
else:
if maskClr:
om = img.GetMask()
mask = wxMaskColour(img, maskClr)
img.SetMask(mask)
if om is not None:
om.Destroy()
if outputName:
newname = outputName
else:
newname = os.path.join(outputDir,
os.path.basename(os.path.splitext(file)[0]) + outExt)
if img.SaveFile(newname, outType):
return 1, file + " converted to " + newname
else:
img = wxImageFromBitmap(img)
if img.SaveFile(newname, outType):
return 1, "ok"
else:
return 0, file + " failed to save!"
def main(args, outType, outExt, doc):
if not args or ("-h" in args):
print doc
return
outputDir = ""
maskClr = None
outputName = None
try:
opts, fileArgs = getopt.getopt(args, "m:n:o:")
except getopt.GetoptError:
print __doc__
return
for opt, val in opts:
if opt == "-m":
maskClr = val
elif opt == "-n":
outputName = val
elif opt == "-o":
outputDir = val
if not fileArgs:
print doc
return
for arg in fileArgs:
for file in glob.glob(arg):
if not os.path.isfile(file):
continue
ok, msg = convert(file, maskClr, outputDir, outputName,
outType, outExt)
print msg

31
wxPython/tools/img2png.py Normal file
View File

@ -0,0 +1,31 @@
#!/usr/bin/env python
"""
img2png.py -- convert several image formats to PNG format
Usage:
img2png.py [options] image_files...
Options:
-o <dir> The directory to place the .png file(s), defaults to
the current directory.
-m <#rrggbb> If the original image has a mask or transparency defined
it will be used by default. You can use this option to
override the default or provide a new mask by specifying
a colour in the image to mark as transparent.
-n <name> A filename to write the .png data to. Defaults to the
basename of the image file + '.png' This option overrides
the -o option.
"""
import sys
import img2img
from wxPython import wx
img2img.main(sys.argv[1:], wx.wxBITMAP_TYPE_PNG, ".png", __doc__)

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python
"""
img2py.py -- Convert an image to XPM format and embed it in a Python
img2py.py -- Convert an image to PNG format and embed it in a Python
module with appropriate code so it can be loaded into
a program at runtime. The benefit is that since it is
Python source code it can be delivered as a .pyc or
@ -36,33 +36,17 @@ Options:
import sys, os, glob, getopt, tempfile, string
import cPickle, cStringIO, zlib
import img2xpm
import img2img
from wxPython import wx
def crunch_data(data, compressed):
# convert the lines to a Python list, pickle it and optionally compress the result.
lines = []
for line in data:
if line[0] == "\"":
# the line is typically (but not always):
# [quote] <data> [quote][comma][newline]
# chop one char from the front
line = line[1:]
# now find the final quote and truncate there
quote = string.rfind(line, "\"")
# and append the remaining data to our list
lines.append(line[:quote])
# pickle, crunch and convert it to a form suitable for embedding in code
data = cPickle.dumps(lines)
# compress it?
if compressed:
data = zlib.compress(data, 9)
data = repr(data)
# convert to a printable format, so it can be in a Python source file
data = repr(data)
# This next bit is borrowed from PIL. It is used to wrap the text intelligently.
fp = cStringIO.StringIO()
@ -141,12 +125,12 @@ def main(args):
# convert the image file to a temporary file
tfname = tempfile.mktemp()
ok, msg = img2xpm.convert(image_file, maskClr, None, tfname)
ok, msg = img2img.convert(image_file, maskClr, None, tfname, wx.wxBITMAP_TYPE_PNG, ".png")
if not ok:
print msg
return
data = open(tfname, "r").readlines()
data = open(tfname, "rb").read()
data = crunch_data(data, compressed)
os.unlink(tfname)
@ -158,32 +142,35 @@ def main(args):
out.write("#" + "-" * 70 + "\n")
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")
out.write("from wxPython.wx import wxImageFromStream, wxBitmapFromImage\n")
if icon:
out.write("from wxPython.wx import wxIconFromXPMData\n")
out.write("from wxPython.wx import wxEmptyIcon\n")
if compressed:
out.write("import cPickle, zlib\n\n\n")
out.write("import cStringIO, zlib\n\n\n")
else:
out.write("import cPickle\n\n\n")
out.write("import cStringIO\n\n\n")
if compressed:
out.write("def get%sData():\n"
" return cPickle.loads(zlib.decompress(\n%s))\n\n"
" return zlib.decompress(\n%s)\n\n"
% (imgName, data))
else:
out.write("def get%sData():\n"
" return cPickle.loads(\n%s)\n\n"
" return %s\n\n"
% (imgName, data))
out.write("def get%sBitmap():\n"
" return wxBitmapFromXPMData(get%sData())\n\n"
" return wxBitmapFromImage(get%sImage())\n\n"
"def get%sImage():\n"
" return wxImageFromBitmap(get%sBitmap())\n\n"
" stream = cStringIO.StringIO(get%sData())\n"
" return wxImageFromStream(stream)\n\n"
% tuple([imgName] * 4))
if icon:
out.write("def get%sIcon():\n"
" return wxIconFromXPMData(get%sData())\n\n"
" icon = wxEmptyIcon()\n"
" icon.CopyFromBitmap(get%sBitmap())\n"
" return icon\n\n"
% tuple([imgName] * 2))
@ -201,7 +188,3 @@ def main(args):
if __name__ == "__main__":
main(sys.argv[1:])

View File

@ -22,80 +22,10 @@ Options:
"""
import sys, os, glob, getopt, string
from wxPython.wx import *
import sys
import img2img
from wxPython import wx
wxInitAllImageHandlers()
def convert(file, maskClr, outputDir, outputName):
if string.lower(os.path.splitext(file)[1]) == ".ico":
icon = wxIcon(file, wxBITMAP_TYPE_ICO)
img = wxBitmapFromIcon(icon)
else:
img = wxBitmap(file, wxBITMAP_TYPE_ANY)
if not img.Ok():
return 0, file + " failed to load!"
else:
if maskClr:
om = img.GetMask()
mask = wxMaskColour(img, maskClr)
img.SetMask(mask)
if om is not None:
om.Destroy()
if outputName:
newname = outputName
else:
newname = os.path.join(outputDir, os.path.basename(os.path.splitext(file)[0]) + ".xpm")
if img.SaveFile(newname, wxBITMAP_TYPE_XPM):
return 1, file + " converted to " + newname
else:
img = wxImageFromBitmap(img)
if img.SaveFile(newname, wxBITMAP_TYPE_XPM):
return 1, "ok"
else:
return 0, file + " failed to save!"
def main(args):
if not args or ("-h" in args):
print __doc__
return
outputDir = ""
maskClr = None
outputName = None
try:
opts, fileArgs = getopt.getopt(args, "m:n:o:")
except getopt.GetoptError:
print __doc__
return
for opt, val in opts:
if opt == "-m":
maskClr = val
elif opt == "-n":
outputName = val
elif opt == "-o":
outputDir = val
if not fileArgs:
print __doc__
return
for arg in fileArgs:
for file in glob.glob(arg):
if not os.path.isfile(file):
continue
ok, msg = convert(file, maskClr, outputDir, outputName)
print msg
if __name__ == "__main__":
main(sys.argv[1:])
img2img.main(sys.argv[1:], wx.wxBITMAP_TYPE_XPM, ".xpm", __doc__)