]> git.saurik.com Git - wxWidgets.git/blame - wxPython/wx/py/PyWrap.py
Script updates
[wxWidgets.git] / wxPython / wx / py / PyWrap.py
CommitLineData
d14a1e28
RD
1"""PyWrap is a command line utility that runs a wxPython program with
2additional runtime-tools, such as PyCrust."""
1fded56b 3
d14a1e28
RD
4__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
5__cvsid__ = "$Id$"
6__revision__ = "$Revision$"[11:-2]
7
8import os
9import sys
10import wx
578b389d 11from wx.py.crust import CrustFrame
d14a1e28
RD
12
13def wrap(app):
14 wx.InitAllImageHandlers()
578b389d 15 frame = CrustFrame()
d14a1e28
RD
16 frame.SetSize((750, 525))
17 frame.Show(True)
18 frame.shell.interp.locals['app'] = app
19 app.MainLoop()
20
d14a1e28
RD
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:
578b389d 41 print "No App class was found."
d14a1e28
RD
42 raise SystemExit
43 app = App()
44 wrap(app)
1fded56b 45
8b9a4190
RD
46if __name__ == '__main__':
47 main()