Changeset b7c7a1c in sasview


Ignore:
Timestamp:
Jan 10, 2011 5:11:09 PM (13 years ago)
Author:
Gervaise Alina <gervyh@…>
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:
992199e
Parents:
9299455
Message:

working on guiframe

Location:
guiframe
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • guiframe/gui_manager.py

    rb5ca223 rb7c7a1c  
    5555        Initialize the Frame object 
    5656        """ 
    57         from local_perspectives.plotting import plotting 
     57         
    5858        wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, 
    5959                          size=(window_width, window_height)) 
     
    8686        # Modify this so that we can specify the directory to look into 
    8787        self.plugins = [] 
     88        #add local plugin 
     89       
     90        from sans.guiframe.local_perspectives.plotting import plotting 
     91        from sans.guiframe.local_perspectives.data_loader import data_loader 
    8892        self.plugins.append(plotting.Plugin()) 
     93        self.plugins.append(data_loader.Plugin()) 
     94         
    8995        self.plugins += self._find_plugins() 
    9096       
     
    375381        return ID 
    376382         
     383    def _populate_file_menu(self): 
     384        """ 
     385        Insert menu item under file menu 
     386        """ 
     387        for plugin in self.plugins: 
     388            if len(plugin.populate_file_menu()) > 0: 
     389                id = wx.NewId() 
     390                for item in plugin.populate_file_menu(): 
     391                    m_name, m_hint, m_handler = item 
     392                    self.filemenu.Append(id, m_name, m_hint) 
     393                    wx.EVT_MENU(self, id, m_handler) 
     394                self.filemenu.AppendSeparator() 
     395                 
    377396    def _setup_menus(self): 
    378397        """ 
     
    380399        """ 
    381400        # Menu 
    382         menubar = wx.MenuBar() 
     401        self._menubar = wx.MenuBar() 
    383402        # File menu 
    384403        self.filemenu = wx.Menu() 
    385404         
    386         id = wx.NewId() 
    387         self.filemenu.Append(id, '&Open', 'Load data file into the application') 
    388         wx.EVT_MENU(self, id, self._on_open) 
    389         #self.filemenu.AppendSeparator() 
    390          
     405        # some menu of plugin to be seen under file menu 
     406        self._populate_file_menu() 
    391407        id = wx.NewId() 
    392408        self.filemenu.Append(id, '&Save', 
     
    400416         
    401417        # Add sub menus 
    402         menubar.Append(self.filemenu, '&File') 
     418        self._menubar.Append(self.filemenu, '&File') 
    403419         
    404420        # Window menu 
     
    425441                                        "Show %s window" % panel.window_caption) 
    426442                        wx.EVT_MENU(self, int(item), self._on_view) 
    427                 menubar.Append(viewmenu, '&Window') 
     443                self._menubar.Append(viewmenu, '&Window') 
    428444 
    429445        # Perspective 
     
    443459                                  "Switch to %s perspective" % plug.sub_menu) 
    444460                    wx.EVT_MENU(self, id, plug.on_perspective) 
    445             menubar.Append(p_menu, '&Perspective') 
     461            self._menubar.Append(p_menu, '&Perspective') 
    446462  
    447463        # Tools menu 
     
    458474                    wx.EVT_MENU(self, id, tool[2]) 
    459475        if toolsmenu is not None: 
    460             menubar.Append(toolsmenu, '&Tools') 
     476            self._menubar.Append(toolsmenu, '&Tools') 
    461477  
    462478        # Help menu 
     
    494510                for (self.next_id, menu, name) in \ 
    495511                    item.populate_menu(self.next_id, self): 
    496                     menubar.Append(menu, name) 
     512                    self._menubar.Append(menu, name) 
    497513                    
    498         menubar.Append(helpmenu, '&Help') 
    499         self.SetMenuBar(menubar) 
     514        self._menubar.Append(helpmenu, '&Help') 
     515        self.SetMenuBar(self._menubar) 
    500516     
    501517    def _on_status_event(self, evt): 
     
    657673        Store info to retrieve in xml before closing the application 
    658674        """ 
    659         try: 
    660             doc = xml.dom.minidom.Document() 
    661             main_node = doc.createElement("file Path") 
    662             doc.appendChild(main_node) 
    663          
    664             for item in self.filePathList: 
    665                 id, menuitem_name, path, title = item 
    666                 pt1 = doc.createElement("File") 
    667                 pt1.setAttribute("name", menuitem_name) 
    668                 pt2 = doc.createElement("path") 
    669                 pt2.appendChild(doc.createTextNode(str(path))) 
    670                 pt1.appendChild(pt2) 
    671                 pt3 = doc.createElement("title") 
    672                 pt3.appendChild(doc.createTextNode(str(title))) 
    673                 pt1.appendChild(pt3) 
    674                 main_node.appendChild(pt1) 
    675              
    676             fd = open("fileOpened.xml",'w') 
    677             fd.write(doc.toprettyxml()) 
    678             fd.close() 
    679         except: 
    680             pass 
    681         #import sys 
    682675        wx.Exit() 
    683676        sys.exit() 
     
    847840                pass 
    848841        return path 
    849      
    850     def load_ascii_1D(self, path): 
    851         """ 
    852         """ 
    853         from .data_loader import load_ascii_1D 
    854         return load_ascii_1D(path) 
    855                    
     842 
    856843class DefaultPanel(wx.Panel): 
    857844    """ 
  • guiframe/local_perspectives/plotting/plotting.py

    r7f84e22 rb7c7a1c  
    3030        self.plot_panels = [] 
    3131        
     32    def is_always_active(self): 
     33        """ 
     34        return True is this plugin is always active even if the user is  
     35        switching between perspectives 
     36        """ 
     37        return True 
     38     
    3239    def populate_menu(self, id, parent): 
    3340        """ 
  • guiframe/plugin_base.py

    rb5ca223 rb7c7a1c  
    3333            Abstract class for gui_manager Plugins. 
    3434        """ 
     35        # Define if the plugin is local to Viewerframe  and always active 
     36        self._always_active = False 
    3537        ## Plug-in name. It will appear on the application menu. 
    3638        self.sub_menu = name      
     
    4446        self.perspective = [] 
    4547         
     48    def set_is_active(self, active=False): 
     49        """ 
     50        """ 
     51        self._always_active = active 
     52         
     53    def is_always_active(self): 
     54        """ 
     55        return True is this plugin is always active and it is local to guiframe 
     56        even if the user is switching between perspectives 
     57        """ 
     58        return self._always_active 
     59     
     60    def populate_file_menu(self): 
     61        """ 
     62        get a menu item and append it under file menu of the application 
     63        return [[menu item name, menu_hint, menu handler]] 
     64        """ 
     65        return [] 
    4666         
    4767    def populate_menu(self, id, parent): 
Note: See TracChangeset for help on using the changeset viewer.