Changeset 278cc25 in sasview


Ignore:
Timestamp:
May 27, 2008 12: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

Location:
guiframe
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • guiframe/aboutbox.py

    r41d466f r278cc25  
    2828    import imp 
    2929    path = os.getcwd() 
    30     if(os.path.isfile("%s/%s.py" % (path, 'config'))): 
    31             fObj, path, descr = imp.find_module('config', [path]) 
    32             config = imp.load_module('config', fObj, path, descr)      
     30    if(os.path.isfile("%s/%s.py" % (path, 'local_config'))) or \ 
     31      (os.path.isfile("%s/%s.pyc" % (path, 'local_config'))): 
     32            fObj, path, descr = imp.find_module('local_config', [path]) 
     33            config = imp.load_module('local_config', fObj, path, descr)   
     34    else: 
     35        # Try simply importing local_config 
     36        import local_config as config 
    3337except: 
     38    # Didn't find local config, load the default  
    3439    import config 
    3540 
  • 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__":  
  • guiframe/local_perspectives/plotting/plotting.py

    r383189f9 r278cc25  
    5252        ## Unique ID (from gui_manager) 
    5353        self.uid = None 
     54         
     55        ## Action IDs for internal call-backs 
     56        self.action_ids = {} 
    5457         
    5558        ## Graph         
     
    8386        # Check axis labels 
    8487        #TODO: Should re-factor this 
    85         if event.plot._xunit != self.graph.prop["xunit"]: 
    86             self.graph.xaxis(event.plot._xaxis, event.plot._xunit) 
    87              
    88         if event.plot._yunit != self.graph.prop["yunit"]: 
    89             self.graph.yaxis(event.plot._yaxis, event.plot._yunit) 
     88        #if event.plot._xunit != self.graph.prop["xunit"]: 
     89        self.graph.xaxis(event.plot._xaxis, event.plot._xunit) 
     90             
     91        #if event.plot._yunit != self.graph.prop["yunit"]: 
     92        self.graph.yaxis(event.plot._yaxis, event.plot._yunit) 
    9093       
    9194        self.graph.render(self) 
     
    100103        slicerpop = PanelMenu() 
    101104        slicerpop.set_plots(self.plots) 
     105                 
     106        # Option to save the data displayed 
     107        id = wx.NewId() 
     108        for plot in self.graph.plottables: 
     109            name = plot.name 
     110            slicerpop.Append(id, "&Save %s points" % name) 
     111            self.action_ids[str(id)] = plot 
     112            wx.EVT_MENU(self, id, self._onSave) 
    102113                 
    103114        # Various plot options 
     
    127138        pos = self.ScreenToClient(pos) 
    128139        self.PopupMenu(slicerpop, pos) 
     140     
     141    def _onSave(self, evt): 
     142        """ 
     143            Save a data set to a text file 
     144            @param evt: Menu event 
     145        """ 
     146        import os 
     147        id = str(evt.GetId()) 
     148        if id in self.action_ids:          
     149             
     150            path = None 
     151            dlg = wx.FileDialog(self, "Choose a file", os.getcwd(), "", "*.txt", wx.SAVE) 
     152            if dlg.ShowModal() == wx.ID_OK: 
     153                path = dlg.GetPath() 
     154                mypath = os.path.basename(path) 
     155                print path 
     156            dlg.Destroy() 
     157             
     158            if not path == None: 
     159                out = open(path, 'w') 
     160                has_errors = True 
     161                if self.action_ids[id].dy==None or self.action_ids[id].dy==[]: 
     162                    has_errors = False 
     163                     
     164                # Sanity check 
     165                if has_errors: 
     166                    try: 
     167                        if len(self.action_ids[id].y) != len(self.action_ids[id].dy): 
     168                            print "Y and dY have different lengths" 
     169                            has_errors = False 
     170                    except: 
     171                        has_errors = False 
     172                 
     173                if has_errors: 
     174                    out.write("<X>   <Y>   <dY>\n") 
     175                else: 
     176                    out.write("<X>   <Y>\n") 
     177                     
     178                for i in range(len(self.action_ids[id].x)): 
     179                    if has_errors: 
     180                        out.write("%g  %g  %g\n" % (self.action_ids[id].x[i],  
     181                                                    self.action_ids[id].y[i], 
     182                                                    self.action_ids[id].dy[i])) 
     183                    else: 
     184                        out.write("%g  %g\n" % (self.action_ids[id].x[i],  
     185                                                self.action_ids[id].y[i])) 
     186                         
     187                out.close() 
     188     
    129189     
    130190    def _onToggleScale(self, event): 
  • guiframe/release_notes.txt

    rfa452e4 r278cc25  
    2323        - Make sure that when a plottable is sent a second time for update, that we replace the lables too! 
    2424        - Add help menu entry for each module    
     25        - Put debug info in log file, because we can't access it from a py2exe executable 
     26        - Allow the application to load perspectives by hand. Then the automatic loading is only 
     27          for additionally installed plug-ins. 
     28        - Fix the damned images directory folder... 
    2529         
Note: See TracChangeset for help on using the changeset viewer.