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