Changeset b5ca223 in sasview


Ignore:
Timestamp:
Jan 10, 2011 12:39:16 PM (11 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:
a0ac888
Parents:
614ce1b1
Message:

make all plugins inheriting from pluginbase in plugin-base.py

Location:
guiframe
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • guiframe/gui_manager.py

    r32c0841 rb5ca223  
    1010################################################################################ 
    1111 
    12 """ 
    13 How-to build an application using guiframe: 
    14  
    15 1- Write a main application script along the lines of dummyapp.py 
    16 2- Write a config script along the lines of config.py, and  
    17     name it local_config.py 
    18 3- Write your plug-ins and place them in a directory called "perspectives". 
    19     - Look at local_perspectives/plotting for an example of a plug-in. 
    20     - A plug-in should define a class called Plugin. See abstract class below. 
    21  
    22 """ 
    23 #TODO: rewrite the status bar monstrosity 
    2412 
    2513import wx 
     
    5745STATE_FILE_EXT = ['.inv', '.fitv', '.prv'] 
    5846 
    59 def quit_guiframe(parent=None): 
    60     """ 
    61     Pop up message to make sure the user wants to quit the application 
    62     """ 
    63     message = "Do you really want to quit \n" 
    64     message += "this application?" 
    65     dial = wx.MessageDialog(parent, message, 'Question', 
    66                        wx.YES_NO|wx.NO_DEFAULT|wx.ICON_QUESTION) 
    67     if dial.ShowModal() == wx.ID_YES: 
    68         return True 
    69     else: 
    70         return False 
    71      
    72 class Plugin: 
    73     """ 
    74     This class defines the interface for a Plugin class 
    75     that can be used by the gui_manager. 
    76      
    77     Plug-ins should be placed in a sub-directory called "perspectives". 
    78     For example, a plug-in called Foo should be place in "perspectives/Foo". 
    79     That directory contains at least two files: 
    80         perspectives/Foo/__init.py contains two lines: 
    81          
    82             PLUGIN_ID = "Foo plug-in 1.0" 
    83             from Foo import * 
    84              
    85         perspectives/Foo/Foo.py contains the definition of the Plugin 
    86         class for the Foo plug-in. The interface of that Plugin class 
    87         should follow the interface of the class you are looking at. 
    88          
    89     See dummyapp.py for a plugin example. 
    90     """ 
    91      
    92     def __init__(self, name="Test_plugin"): 
    93         """ 
    94             Abstract class for gui_manager Plugins. 
    95         """ 
    96         ## Plug-in name. It will appear on the application menu. 
    97         self.sub_menu = name      
    98          
    99         ## Reference to the parent window. Filled by get_panels() below. 
    100         self.parent = None 
    101          
    102         ## List of panels that you would like to open in AUI windows 
    103         #  for your plug-in. This defines your plug-in "perspective" 
    104         self.perspective = [] 
    105          
    106          
    107     def populate_menu(self, id, parent): 
    108         """ 
    109         Create and return the list of application menu 
    110         items for the plug-in.  
    111          
    112         :param id: deprecated. Un-used. 
    113         :param parent: parent window 
    114          
    115         :return: plug-in menu 
    116          
    117         """ 
    118         return [] 
    119      
    120     def get_panels(self, parent): 
    121         """ 
    122         Create and return the list of wx.Panels for your plug-in. 
    123         Define the plug-in perspective. 
    124          
    125         Panels should inherit from DefaultPanel defined below, 
    126         or should present the same interface. They must define 
    127         "window_caption" and "window_name". 
    128          
    129         :param parent: parent window 
    130          
    131         :return: list of panels 
    132          
    133         """ 
    134         ## Save a reference to the parent 
    135         self.parent = parent 
    136          
    137         # Return the list of panels 
    138         return [] 
    139      
    140     def get_tools(self): 
    141         """ 
    142         Returns a set of menu entries for tools 
    143         """ 
    144         return [] 
    145          
    146      
    147     def get_context_menu(self, graph=None): 
    148         """ 
    149         This method is optional. 
    150      
    151         When the context menu of a plot is rendered, the  
    152         get_context_menu method will be called to give you a  
    153         chance to add a menu item to the context menu. 
    154          
    155         A ref to a Graph object is passed so that you can 
    156         investigate the plot content and decide whether you 
    157         need to add items to the context menu.   
    158          
    159         This method returns a list of menu items. 
    160         Each item is itself a list defining the text to  
    161         appear in the menu, a tool-tip help text, and a 
    162         call-back method. 
    163          
    164         :param graph: the Graph object to which we attach the context menu 
    165          
    166         :return: a list of menu items with call-back function 
    167          
    168         """ 
    169         return [] 
    170      
    171     def get_perspective(self): 
    172         """ 
    173         Get the list of panel names for this perspective 
    174         """ 
    175         return self.perspective 
    176      
    177     def on_perspective(self, event): 
    178         """ 
    179         Call back function for the perspective menu item. 
    180         We notify the parent window that the perspective 
    181         has changed. 
    182          
    183         :param event: menu event 
    184          
    185         """ 
    186         self.parent.set_perspective(self.perspective) 
    187      
    188     def post_init(self): 
    189         """ 
    190         Post initialization call back to close the loose ends 
    191         """ 
    192         pass 
    193      
    194     def set_default_perspective(self): 
    195         """ 
    196        Call back method that True to notify the parent that the current plug-in 
    197        can be set as default  perspective. 
    198        when returning False, the plug-in is not candidate for an automatic  
    199        default perspective setting 
    200         """ 
    201         return False 
     47 
    20248 
    20349class ViewerFrame(wx.Frame): 
     
    836682        wx.Exit() 
    837683        sys.exit() 
    838                       
     684                  
     685    def quit_guiframe(self): 
     686        """ 
     687        Pop up message to make sure the user wants to quit the application 
     688        """ 
     689        message = "Do you really want to quit \n" 
     690        message += "this application?" 
     691        dial = wx.MessageDialog(self, message, 'Question', 
     692                           wx.YES_NO|wx.YES_DEFAULT|wx.ICON_QUESTION) 
     693        if dial.ShowModal() == wx.ID_YES: 
     694            return True 
     695        else: 
     696            return False     
     697         
    839698    def Close(self, event=None): 
    840699        """ 
    841700        Quit the application 
    842701        """ 
    843         flag = quit_guiframe(parent=self) 
     702        flag = self.quit_guiframe() 
    844703        if flag: 
    845704            #import sys 
  • guiframe/statusbar.py

    r32c0841 rb5ca223  
    246246        if type.lower() == "start": 
    247247            self.nb_start += 1 
    248             self.timer.Stop() 
     248            #self.timer.Stop() 
    249249            self.progress += 10 
    250250            self.gauge.SetValue(int(self.progress))  
     
    254254        if type.lower() == "progress": 
    255255            self.nb_progress += 1 
    256             self.timer.Start(100) 
     256            self.timer.Start(0) 
    257257            self.gauge.Pulse() 
    258258        if type.lower() == "update": 
Note: See TracChangeset for help on using the changeset viewer.