]> git.saurik.com Git - wxWidgets.git/blame_incremental - wxPython/wx/py/PyWrap.py
Script updates
[wxWidgets.git] / wxPython / wx / py / PyWrap.py
... / ...
CommitLineData
1"""PyWrap is a command line utility that runs a wxPython program with
2additional runtime-tools, such as PyCrust."""
3
4__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
5__cvsid__ = "$Id$"
6__revision__ = "$Revision$"[11:-2]
7
8import os
9import sys
10import wx
11from wx.py.crust import CrustFrame
12
13def wrap(app):
14 wx.InitAllImageHandlers()
15 frame = CrustFrame()
16 frame.SetSize((750, 525))
17 frame.Show(True)
18 frame.shell.interp.locals['app'] = app
19 app.MainLoop()
20
21def main(modulename=None):
22 sys.path.insert(0, os.curdir)
23 if not modulename:
24 if len(sys.argv) < 2:
25 print "Please specify a module name."
26 raise SystemExit
27 modulename = sys.argv[1]
28 if modulename.endswith('.py'):
29 modulename = modulename[:-3]
30 module = __import__(modulename)
31 # Find the App class.
32 App = None
33 d = module.__dict__
34 for item in d.keys():
35 try:
36 if issubclass(d[item], wx.App):
37 App = d[item]
38 except (NameError, TypeError):
39 pass
40 if App is None:
41 print "No App class was found."
42 raise SystemExit
43 app = App()
44 wrap(app)
45
46if __name__ == '__main__':
47 main()