]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/PyShell.py
1 """PyShell is a python shell application."""
3 # The next two lines, and the other code below that makes use of
4 # ``__main__`` and ``original``, serve the purpose of cleaning up the
5 # main namespace to look as much as possible like the regular Python
8 original
= __main__
.__dict
__.keys()
10 __author__
= "Patrick K. O'Brien <pobrien@orbtech.com>"
12 __revision__
= "$Revision$"[11:-2]
18 """PyShell standalone application."""
25 self
.SetAppName("pyshell")
26 confDir
= wx
.StandardPaths
.Get().GetUserDataDir()
27 if not os
.path
.exists(confDir
):
29 fileName
= os
.path
.join(confDir
, 'config')
30 self
.config
= wx
.FileConfig(localFilename
=fileName
)
31 self
.config
.SetRecordDefaults(True)
33 self
.frame
= py
.shell
.ShellFrame(config
=self
.config
, dataDir
=confDir
)
35 self
.SetTopWindow(self
.frame
)
39 The main() function needs to handle being imported, such as with the
40 pyshell script that wxPython installs:
44 from wx.py.PyShell import main
49 """The main function for the PyShell program."""
50 # Cleanup the main namespace, leaving the App class.
52 md
= __main__
.__dict
__
56 if key
not in keepers
:
58 # Create an application instance.
60 # Cleanup the main namespace some more.
61 if md
.has_key('App') and md
['App'] is App
:
63 if md
.has_key('__main__') and md
['__main__'] is __main__
:
65 # Mimic the contents of the standard Python shell's sys.path.
69 # Add the application object to the sys module's namespace.
70 # This allows a shell user to do:
72 # >>> sys.app.whatever
75 # Start the wxPython event loop.
78 if __name__
== '__main__':