summaryrefslogtreecommitdiff
path: root/lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py
diff options
context:
space:
mode:
authorrahulp132020-03-17 14:55:41 +0530
committerrahulp132020-03-17 14:55:41 +0530
commit296443137f4288cb030e92859ccfbe3204bc1088 (patch)
treeca4798c2da1e7244edc3bc108d81b462b537aea2 /lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py
parent0db48f6533517ecebfd9f0693f89deca28408b76 (diff)
downloadKiCad-eSim-296443137f4288cb030e92859ccfbe3204bc1088.tar.gz
KiCad-eSim-296443137f4288cb030e92859ccfbe3204bc1088.tar.bz2
KiCad-eSim-296443137f4288cb030e92859ccfbe3204bc1088.zip
initial commit
Diffstat (limited to 'lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py')
-rw-r--r--lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py b/lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py
new file mode 100644
index 0000000..d48409c
--- /dev/null
+++ b/lib/python2.7/site-packages/wx-3.0-msw/wx/py/PyShell.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python2
+"""PyShell is a python shell application."""
+
+# The next two lines, and the other code below that makes use of
+# ``__main__`` and ``original``, serve the purpose of cleaning up the
+# main namespace to look as much as possible like the regular Python
+# shell environment.
+import __main__
+original = __main__.__dict__.keys()
+
+__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
+__cvsid__ = "$Id$"
+__revision__ = "$Revision$"[11:-2]
+
+import wx
+import os
+
+class App(wx.App):
+ """PyShell standalone application."""
+
+ def OnInit(self):
+ import os
+ import wx
+ from wx import py
+
+ self.SetAppName("pyshell")
+ confDir = wx.StandardPaths.Get().GetUserDataDir()
+ if not os.path.exists(confDir):
+ os.mkdir(confDir)
+ fileName = os.path.join(confDir, 'config')
+ self.config = wx.FileConfig(localFilename=fileName)
+ self.config.SetRecordDefaults(True)
+
+ self.frame = py.shell.ShellFrame(config=self.config, dataDir=confDir)
+ self.frame.Show()
+ self.SetTopWindow(self.frame)
+ return True
+
+'''
+The main() function needs to handle being imported, such as with the
+pyshell script that wxPython installs:
+
+ #!/usr/bin/env python2
+
+ from wx.py.PyShell import main
+ main()
+'''
+
+def main():
+ """The main function for the PyShell program."""
+ # Cleanup the main namespace, leaving the App class.
+ import __main__
+ md = __main__.__dict__
+ keepers = original
+ keepers.append('App')
+ for key in md.keys():
+ if key not in keepers:
+ del md[key]
+ # Create an application instance.
+ app = App(0)
+ # Cleanup the main namespace some more.
+ if md.has_key('App') and md['App'] is App:
+ del md['App']
+ if md.has_key('__main__') and md['__main__'] is __main__:
+ del md['__main__']
+ # Mimic the contents of the standard Python shell's sys.path.
+ import sys
+ if sys.path[0]:
+ sys.path[0] = ''
+ # Add the application object to the sys module's namespace.
+ # This allows a shell user to do:
+ # >>> import sys
+ # >>> sys.app.whatever
+ sys.app = app
+ del sys
+ # Start the wxPython event loop.
+ app.MainLoop()
+
+if __name__ == '__main__':
+ main()