Changeset 278cc25 in sasview for guiframe/gui_manager.py
- Timestamp:
- May 27, 2008 2:32:45 PM (16 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
radfcab3 r278cc25 15 15 import imp 16 16 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'))): 18 19 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" 20 23 except: 21 24 # Didn't find local config, load the default … … 39 42 40 43 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)) 42 47 43 48 ## Application manager … … 58 63 self.defaultPanel = DefaultPanel(self, -1, style=wx.RAISED_BORDER) 59 64 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() 67 66 68 67 # Register the close event so it calls our own method … … 71 70 self.Bind(EVT_STATUS, self._on_status_event) 72 71 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 73 81 def _setup_layout(self): 74 82 """ … … 86 94 87 95 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) 88 110 89 111 def _find_plugins(self, dir="perspectives"): … … 96 118 print "Looking for plug-ins in %s" % dir 97 119 # 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 98 128 plugins = [] 99 129 # Go through files in panels directory … … 113 143 try: 114 144 if toks[1]=='': 145 f.write("trying to import \n") 115 146 mod_path = '.'.join([dir, name]) 147 f.write("mod_path= %s\n" % mod_path) 116 148 module = __import__(mod_path, globals(), locals(), [name]) 149 f.write(str(module)+'\n') 117 150 else: 118 151 (file, path, info) = imp.find_module(name, path) … … 128 161 except: 129 162 print sys.exc_value 163 f.write(str(sys.exc_value)+'\n') 130 164 finally: 131 165 if not file==None: … … 134 168 # Should raise and catch at a higher level and display error on status bar 135 169 pass 170 f.write(str(plugins)+'\n') 171 f.close() 136 172 return plugins 137 173 … … 516 552 print "Special?", self.frame.special.__class__.__name__ 517 553 self.frame.special.SetCurrent() 518 self.frame.post_init()519 554 self.SetTopWindow(self.frame) 520 555 return True … … 527 562 self.frame.set_manager(manager) 528 563 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 529 577 530 578 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.