[Bio] / ModelEditor / ModelEditor Repository:
ViewVC logotype

Diff of /ModelEditor/ModelEditor

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9, Tue Feb 1 16:06:14 2005 UTC revision 1.10, Fri Mar 11 21:33:13 2005 UTC
# Line 1  Line 1 
1  #!/usr/bin/env python  #!/bin/sh
2    
3  #import signal  # On some systems you must use pythonw to invoke wx apps and on others
4  from wxPython.wx import *  # you don't.  Hide that via this script.
5    
 from KahApp.KahConfigMgr import KahConfigMgr  
 from ModelEditor.MainLayout        import MainLayout  
 from ModelEditor.RXpanel           import RXPanel  
 from ModelEditor.RecoElempanel     import RecoElempanel  
 from ModelEditor.Catalogpanel      import Catalogpanel  
 from ModelEditor.MetabolitePanel   import MetabolitePanel  
 from ModelEditor.EnzymeWindow      import EnzymeWindow  
 from ModelEditor.HelpPanel         import HelpPanel  
 from ModelEditor.FontManager       import FontManager  
 from ModelEditor.MainMenuBar       import MainMenuBar  
 from KahChemDb.KahChemDbDataFactory import KahChemDbDataFactory  
 from KahDataServices.KahDbDataFactory  import KahDbDataFactory  
 from CatalogServices.Catalog import Catalog  
   
 #need to change panel to Panel. lower case panel is already in cvs.  
   
 from wxPython.grid import *  
   
   
 class MyApp(wxApp):  
     def OnInit(self):  
         frame = Gui(None, -1, "test")  
         frame.Show()  
         return 1  
   
   
 class Gui(MainLayout):  
   
     def __init__(self, *args, **kwds):  
   
         #self.factoryMgr = None  
         MainLayout.__init__(self, *args, **kwds)  
   
         self.configMgr = KahConfigMgr()  
         self.setupConfig()  
   
         self.rootId        = None        # root ID for recoelem tree.  why here??  
         self.catalogRootId = None        # root ID for catalog tree.  
         self.fontManager    = FontManager(self)  
         self.mainMenuBar    = MainMenuBar(self)  
         self.rx             = RXPanel(self)  
         self.re             = RecoElempanel(self)  
         self.cat            = Catalogpanel(self)  
         self.met            = MetabolitePanel(self)  
         self.enzyme         = EnzymeWindow(self)  
         self.help           = HelpPanel(self)  
         self.meAGMgr        = None       #MeAGMgr instance to manage ag issues  
   
         EVT_CLOSE(self, self.mainMenuBar.exitApp)  
   
         #signal.signal(signal.SIGINT, self.signalHandler)  
         #signal.signal(signal.SIGTERM, self.signalHandler)  
         #signal.signal(signal.SIGHUP, self.signalHandler)  
   
         self.doDefaultDataFactories()  
         self.doInitialPlugins()  
   
         return  
   
     #------------------------------------------------------------------------  
     def getConfigMgr( self ):  
     #------------------------------------------------------------------------  
         return self.configMgr  
   
     #------------------------------------------------------------------------  
     def setupConfig( self ):  
     #------------------------------------------------------------------------  
   
         # Config ourselves.  Unusual usage of configMgr.  
   
         self.configMgr.newSection( "ModelEditor" )  
         cfg = self.configMgr.getSection( "ModelEditor" )  
   
         cfg.regString( "DefaultDataFactory", "kahchoo/bss@db02" )  
         cfg.regString( "DefaultDataFactoryDbType", "oracle" )  
         cfg.regString( "DefaultChemDb", "pgsql:5432:kahdb:trust:inme" )  
         cfg.regString( "DefaultChemDbType", "postgres" )  
         cfg.regStringList( "PluginList", [] )  
   
         # now load the config  
   
         self.configMgr.loadConfigFile( "ModelEditor.cfg" )  
         self.configMgr.dump()  
         return  
   
   
     #------------------------------------------------------------------------  
     def doDefaultDataFactories(self):  
     #------------------------------------------------------------------------  
   
         cfg    = self.configMgr.getSection( "ModelEditor" )  
         ddf    =  cfg.getString("DefaultDataFactory")  
         ddft   = cfg.getString( "DefaultDataFactoryDbType")  
         dchem  = cfg.getString( "DefaultChemDb")  
         dchemt = cfg.getString( "DefaultChemDbType")  
   
         # nb: making these datafactories auto registeres them in catalog  
   
         try:  
             chem = KahChemDbDataFactory( dchem, dchemt )  
         except NotImplementedError:  
             pass  
   
         try:  
             df   = KahDbDataFactory( ddf, ddft )  
         except NotImplementedError:  
             pass  
   
         return  
   
     #------------------------------------------------------------------------  
     def doInitialPlugins(self):  
     #------------------------------------------------------------------------  
   
         cfg    = self.configMgr.getSection( "ModelEditor" )  
   
         pluginList = cfg.getStringList("PluginList")  
         for p in pluginList:  
             print "trying to get plugin named: ", p  
   
             try:  
                 self.mainMenuBar.doAddPlugIn( p )  
             except ImportError, e:  
                 print "Could not import %s: %s" % (p, e)  
             except LookupError:  
                 print "No register hook called 'register' found in plugin"  
   
         return  
   
     #------------------------------------------------------------------------  
     def error( self, message):  
     #------------------------------------------------------------------------  
         dlg = wxMessageDialog(self, message, style=wxOK)  
         dlg.ShowModal()  
         dlg.Destroy()  
         return  
   
     #------------------------------------------------------------------------  
     def signalHandler(self, signum, frame):  
     #------------------------------------------------------------------------  
         """  
         signal handler for sigint, sigterm, and sigHUP to let us close down cleanly.  
         We need to disconnect from AG.  
         """  
   
         print "ModelEditor:signalHandler: caught signal=", signum  
   
         try:  
             theMgr = self.cat.meAGMgr  
             if (not theMgr == None):  
                 theMgr.done()  
         except Exception, e:  
             print e  
   
         self.mainMenuBar.exitApp(None)  
         return  
   
   
 ########################################################################  
 if __name__ == "__main__":  
     app = MyApp(0)  
     app.MainLoop()  
6    
7    if [ .${RTARCH} = .mac ]; then
8       pythonw `which ModelEditorExe`
9    else
10       python `which ModelEditorExe`
11    fi

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3