]>
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]
16 print "PID:", os
.getpid()
20 """PyShell standalone application."""
27 self
.SetAppName("pyshell")
28 confDir
= wx
.StandardPaths
.Get().GetUserDataDir()
29 if not os
.path
.exists(confDir
):
31 fileName
= os
.path
.join(confDir
, 'config')
32 self
.config
= wx
.FileConfig(localFilename
=fileName
)
33 self
.config
.SetRecordDefaults(True)
35 self
.frame
= py
.shell
.ShellFrame(config
=self
.config
, dataDir
=confDir
)
37 self
.SetTopWindow(self
.frame
)
41 The main() function needs to handle being imported, such as with the
42 pyshell script that wxPython installs:
46 from wx.py.PyShell import main
51 """The main function for the PyShell program."""
52 # Cleanup the main namespace, leaving the App class.
54 md
= __main__
.__dict
__
58 if key
not in keepers
:
60 # Create an application instance.
62 # Cleanup the main namespace some more.
63 if md
.has_key('App') and md
['App'] is App
:
65 if md
.has_key('__main__') and md
['__main__'] is __main__
:
67 # Mimic the contents of the standard Python shell's sys.path.
71 # Add the application object to the sys module's namespace.
72 # This allows a shell user to do:
74 # >>> sys.app.whatever
77 # Start the wxPython event loop.
80 if __name__
== '__main__':