Changeset 278cc25 in sasview for guiframe/gui_manager.py


Ignore:
Timestamp:
May 27, 2008 2:32:45 PM (16 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
4a5de6f
Parents:
14b8154
Message:

Allow adding base perspectives to an app (as opposed of only dynamically finding them out).
Modified plot label update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • guiframe/gui_manager.py

    radfcab3 r278cc25  
    1515    import imp 
    1616    path = os.getcwd() 
    17     if(os.path.isfile("%s/%s.py" % (path, 'config'))): 
     17    if(os.path.isfile("%s/%s.py" % (path, 'config'))) or \ 
     18      (os.path.isfile("%s/%s.pyc" % (path, 'config'))): 
    1819            fObj, path, descr = imp.find_module('config', [path]) 
    19             config = imp.load_module('config', fObj, path, descr)      
     20            config = imp.load_module('config', fObj, path, descr)   
     21    else: 
     22        raise RuntimeError, "Look for default config"    
    2023except: 
    2124    # Didn't find local config, load the default  
     
    3942         
    4043        path = os.path.dirname(__file__) 
    41         self.SetIcon(wx.Icon(os.path.join(path,'images/ball.ico'), wx.BITMAP_TYPE_ICO)) 
     44        ico_file = os.path.join(path,'images/ball.ico') 
     45        if os.path.isfile(ico_file): 
     46            self.SetIcon(wx.Icon(ico_file, wx.BITMAP_TYPE_ICO)) 
    4247         
    4348        ## Application manager 
     
    5863        self.defaultPanel    = DefaultPanel(self, -1, style=wx.RAISED_BORDER) 
    5964 
    60         # Set up the layout 
    61         self._setup_layout() 
    62          
    63         # Set up the menu 
    64         self._setup_menus() 
    65          
    66         self.Fit() 
     65        # self.build_gui() 
    6766        
    6867        # Register the close event so it calls our own method 
     
    7170        self.Bind(EVT_STATUS, self._on_status_event) 
    7271              
     72    def build_gui(self): 
     73        # Set up the layout 
     74        self._setup_layout() 
     75         
     76        # Set up the menu 
     77        self._setup_menus() 
     78         
     79        self.Fit() 
     80              
    7381    def _setup_layout(self): 
    7482        """ 
     
    8694         
    8795        self._mgr.Update() 
     96 
     97    def add_perspective(self, plugin): 
     98        """ 
     99            Add a perspective if it doesn't already 
     100            exist. 
     101        """ 
     102        is_loaded = False 
     103        for item in self.plugins: 
     104             if plugin.__class__==item.PLUGIN_ID.__class__: 
     105                 print "Plugin %s already loaded" % plugin.__class__.__name__ 
     106                 is_loaded = True 
     107                  
     108        if not is_loaded: 
     109            self.plugins.append(plugin) 
    88110       
    89111    def _find_plugins(self, dir="perspectives"): 
     
    96118        print "Looking for plug-ins in %s" % dir 
    97119        # List of plug-in objects 
     120         
     121        #path_exe = os.getcwd() 
     122        #path_plugs = os.path.join(path_exe, dir) 
     123        f = open("load.log",'w')  
     124        f.write(os.getcwd()+'\n\n') 
     125        #f.write(str(os.listdir(dir))+'\n') 
     126         
     127         
    98128        plugins = [] 
    99129        # Go through files in panels directory 
     
    113143                    try: 
    114144                        if toks[1]=='': 
     145                            f.write("trying to import \n") 
    115146                            mod_path = '.'.join([dir, name]) 
     147                            f.write("mod_path= %s\n" % mod_path) 
    116148                            module = __import__(mod_path, globals(), locals(), [name]) 
     149                            f.write(str(module)+'\n') 
    117150                        else: 
    118151                            (file, path, info) = imp.find_module(name, path) 
     
    128161                    except: 
    129162                        print sys.exc_value 
     163                        f.write(str(sys.exc_value)+'\n') 
    130164                    finally: 
    131165                        if not file==None: 
     
    134168            # Should raise and catch at a higher level and display error on status bar 
    135169            pass    
     170        f.write(str(plugins)+'\n') 
     171        f.close() 
    136172        return plugins 
    137173     
     
    516552            print "Special?", self.frame.special.__class__.__name__ 
    517553            self.frame.special.SetCurrent() 
    518         self.frame.post_init() 
    519554        self.SetTopWindow(self.frame) 
    520555        return True 
     
    527562        self.frame.set_manager(manager) 
    528563         
     564    def build_gui(self): 
     565        """ 
     566            Build the GUI 
     567        """ 
     568        self.frame.build_gui() 
     569        self.frame.post_init() 
     570         
     571    def add_perspective(self, perspective): 
     572        """ 
     573            Manually add a perspective to the application GUI 
     574        """ 
     575        self.frame.add_perspective(perspective) 
     576         
    529577 
    530578if __name__ == "__main__":  
Note: See TracChangeset for help on using the changeset viewer.