]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/py/PyCrust.py
   1 """PyCrust is a python shell and namespace browser 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] 
  17     """PyCrust standalone application.""" 
  24         self
.SetAppName("pycrust") 
  25         confDir 
= wx
.StandardPaths
.Get().GetUserDataDir() 
  26         if not os
.path
.exists(confDir
): 
  28         fileName 
= os
.path
.join(confDir
, 'config') 
  29         self
.config 
= wx
.FileConfig(localFilename
=fileName
) 
  30         self
.config
.SetRecordDefaults(True) 
  32         self
.frame 
= py
.crust
.CrustFrame(config
=self
.config
, dataDir
=confDir
) 
  33 ##        self.frame.startupFileName = os.path.join(confDir,'pycrust_startup') 
  34 ##        self.frame.historyFileName = os.path.join(confDir,'pycrust_history') 
  36         self
.SetTopWindow(self
.frame
) 
  41 The main() function needs to handle being imported, such as with the 
  42 pycrust script that wxPython installs: 
  46     from wx.py.PyCrust import main 
  51     """The main function for the PyCrust 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     # Mimic the contents of the standard Python shell's sys.path. 
  66     # Add the application object to the sys module's namespace. 
  67     # This allows a shell user to do: 
  69     # >>> sys.app.whatever 
  72     # Cleanup the main namespace some more. 
  73     if md
.has_key('App') and md
['App'] is App
: 
  75     if md
.has_key('__main__') and md
['__main__'] is __main__
: 
  77     # Start the wxPython event loop. 
  80 if __name__ 
== '__main__':