]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/PyWrap.py
Added wxGetKeyState
[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 crust import CrustFrame as Frame
12
13 try:
14 True
15 except NameError:
16 True = 1==1
17 False = 1==0
18
19
20 def wrap(app):
21 wx.InitAllImageHandlers()
22 frame = Frame()
23 frame.SetSize((750, 525))
24 frame.Show(True)
25 frame.shell.interp.locals['app'] = app
26 app.MainLoop()
27
28
29 def main(modulename=None):
30 sys.path.insert(0, os.curdir)
31 if not modulename:
32 if len(sys.argv) < 2:
33 print "Please specify a module name."
34 raise SystemExit
35 modulename = sys.argv[1]
36 if modulename.endswith('.py'):
37 modulename = modulename[:-3]
38 module = __import__(modulename)
39 # Find the App class.
40 App = None
41 d = module.__dict__
42 for item in d.keys():
43 try:
44 if issubclass(d[item], wx.App):
45 App = d[item]
46 except (NameError, TypeError):
47 pass
48 if App is None:
49 print "No App class found."
50 raise SystemExit
51 app = App()
52 wrap(app)
53
54
55 if __name__ == '__main__':
56 main()