]>
Commit | Line | Data |
---|---|---|
d14a1e28 RD |
1 | """PyWrap is a command line utility that runs a wxPython program with |
2 | additional 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 | ||
d40bbd4d PB |
8 | import wx |
9 | from wx import py | |
10 | ||
d14a1e28 RD |
11 | import os |
12 | import sys | |
d14a1e28 RD |
13 | |
14 | def wrap(app): | |
15 | wx.InitAllImageHandlers() | |
d40bbd4d | 16 | frame = py.crust.CrustFrame() |
d14a1e28 RD |
17 | frame.SetSize((750, 525)) |
18 | frame.Show(True) | |
19 | frame.shell.interp.locals['app'] = app | |
20 | app.MainLoop() | |
21 | ||
d14a1e28 RD |
22 | def 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: | |
578b389d | 42 | print "No App class was found." |
d14a1e28 RD |
43 | raise SystemExit |
44 | app = App() | |
45 | wrap(app) | |
1fded56b | 46 | |
8b9a4190 RD |
47 | if __name__ == '__main__': |
48 | main() |