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