]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/PyWrap.py
Docstring tweaks, fixed typo, etc.
[wxWidgets.git] / wxPython / wx / py / PyWrap.py
1 """PyWrap is a command line utility that runs a wxPython program with
2 additional runtime-tools, such as PyCrust."""
3
4 __author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
5 __cvsid__ = "$Id$"
6 __revision__ = "$Revision$"[11:-2]
7
8 import os
9 import sys
10 import wx
11 from wx.py.crust import CrustFrame
12
13 def 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
21 def 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
46 if __name__ == '__main__':
47 main()