Changeset 0fa825c in sasview


Ignore:
Timestamp:
Apr 2, 2015 12:29:59 PM (9 years ago)
Author:
krzywon
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:
7b1f4e3
Parents:
3d250da3
Message:

The perspectives panel no longer shifts up when changing perspectives.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/guiframe/plugin_base.py

    r79492222 r0fa825c  
     1""" 
     2Defines the interface for a Plugin class that can be used by the gui_manager. 
     3""" 
     4 
    15################################################################################ 
    26#This software was developed by the University of Tennessee as part of the 
    37#Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    4 #project funded by the US National Science Foundation.  
     8#project funded by the US National Science Foundation. 
    59# 
    610#See the license text in license.txt 
     
    812#copyright 2008, University of Tennessee 
    913################################################################################ 
    10   
     14 
    1115class PluginBase: 
    1216    """ 
    1317    This class defines the interface for a Plugin class 
    1418    that can be used by the gui_manager. 
    15      
     19 
    1620    Plug-ins should be placed in a sub-directory called "perspectives". 
    1721    For example, a plug-in called Foo should be place in "perspectives/Foo". 
     
    1923 
    2024    1. perspectives/Foo/__init__.py contains two lines: :: 
    21          
     25 
    2226        PLUGIN_ID = "Foo plug-in 1.0" 
    2327        from Foo import * 
    24              
     28 
    2529    2. perspectives/Foo/Foo.py contains the definition of the Plugin 
    2630       class for the Foo plug-in. The interface of that Plugin class 
    2731       should follow the interface of the class you are looking at. 
    28          
     32 
    2933    See dummyapp.py for a plugin example. 
    3034    """ 
    31      
     35 
    3236    def __init__(self, name="Test_plugin", standalone=True): 
    3337        """ 
     
    3741        self._always_active = False 
    3842        ## Plug-in name. It will appear on the application menu. 
    39         self.sub_menu = name      
     43        self.sub_menu = name 
    4044        #standalone flag 
    4145        self.standalone = standalone 
     
    4448        self.frame = None 
    4549        #plugin state reader 
    46         self.state_reader = None  
     50        self.state_reader = None 
    4751        self._extensions = '' 
    4852        ## List of panels that you would like to open in AUI windows 
     
    5559        self.id = -1 
    5660        self.batch_capable = self.get_batch_capable() 
    57      
     61 
    5862    def get_batch_capable(self): 
    5963        """ 
     
    6165        """ 
    6266        return False 
    63           
     67 
    6468    def add_color(self, color, id): 
    6569        """ 
    6670        Adds color to a plugin 
    6771        """ 
    68          
     72 
    6973    def clear_panel(self): 
    7074        """ 
    7175        clear all related panels 
    7276        """ 
     77 
    7378    def get_extensions(self): 
    7479        """ 
     
    7681        """ 
    7782        return self.state_reader, self._extensions 
    78      
     83 
    7984    def can_load_data(self): 
    8085        """ 
     
    8287        """ 
    8388        return False 
    84      
     89 
    8590    def use_data(self): 
    8691        """ 
     
    8893        """ 
    8994        return True 
    90      
     95 
    9196    def is_in_use(self, data_id): 
    9297        """ 
    9398        get a  data id a list of data name if data data is 
    9499         currently used by the plugin and the name of the plugin 
    95          
     100 
    96101        data_name = 'None' 
    97102        in_use = False 
     
    99104        """ 
    100105        return [] 
    101      
     106 
    102107    def delete_data(self, data_id): 
    103108        """ 
    104109        Delete all references of data which id are in data_list.  
    105110        """ 
    106          
     111 
    107112    def load_data(self, event): 
    108113        """ 
     
    110115        """ 
    111116        raise NotImplementedError 
    112   
     117 
    113118    def load_folder(self, event): 
    114119        """ 
     
    116121        """ 
    117122        raise NotImplementedError 
    118      
     123 
    119124    def set_is_active(self, active=False): 
    120125        """ 
     126        Set if the perspective is always active 
    121127        """ 
    122128        self._always_active = active 
    123          
     129 
    124130    def is_always_active(self): 
    125131        """ 
     
    128134        """ 
    129135        return self._always_active 
    130      
     136 
    131137    def populate_file_menu(self): 
    132138        """ 
     
    134140        """ 
    135141        return [] 
    136      
     142 
    137143    def populate_menu(self, parent): 
    138144        """ 
    139145        Create and return the list of application menu 
    140146        items for the plug-in.  
    141          
     147 
    142148        :param parent: parent window 
    143          
     149 
    144150        :return: plug-in menu 
    145          
    146         """ 
    147         return [] 
    148      
     151 
     152        """ 
     153        return [] 
     154 
    149155    def get_frame(self): 
    150156        """ 
     
    160166            self.frame.EnableCloseButton(False) 
    161167            self.frame.Show(False) 
    162      
     168 
    163169    def get_panels(self, parent): 
    164170        """ 
    165171        Create and return the list of wx.Panels for your plug-in. 
    166172        Define the plug-in perspective. 
    167          
     173 
    168174        Panels should inherit from DefaultPanel defined below, 
    169175        or should present the same interface. They must define 
    170176        "window_caption" and "window_name". 
    171          
     177 
    172178        :param parent: parent window 
    173          
     179 
    174180        :return: list of panels 
    175          
     181 
    176182        """ 
    177183        ## Save a reference to the parent 
    178184        self.parent = parent 
    179          
     185 
    180186        # Return the list of panels 
    181187        return [] 
    182      
    183   
     188 
    184189    def get_tools(self): 
    185190        """ 
     
    187192        """ 
    188193        return [] 
    189          
    190      
     194 
    191195    def get_context_menu(self, plotpanel=None): 
    192196        """ 
    193197        This method is optional. 
    194      
    195         When the context menu of a plot is rendered, the  
    196         get_context_menu method will be called to give you a  
     198 
     199        When the context menu of a plot is rendered, the 
     200        get_context_menu method will be called to give you a 
    197201        chance to add a menu item to the context menu. 
    198          
     202 
    199203        A ref to a plotpanel object is passed so that you can 
    200204        investigate the plot content and decide whether you 
    201         need to add items to the context menu.   
    202          
     205        need to add items to the context menu. 
     206 
    203207        This method returns a list of menu items. 
    204         Each item is itself a list defining the text to  
     208        Each item is itself a list defining the text to 
    205209        appear in the menu, a tool-tip help text, and a 
    206210        call-back method. 
    207          
     211 
    208212        :param graph: the Graph object to which we attach the context menu 
    209          
     213 
    210214        :return: a list of menu items with call-back function 
    211          
    212         """ 
    213         return [] 
    214      
     215        """ 
     216        return [] 
     217 
    215218    def get_perspective(self): 
    216219        """ 
     
    218221        """ 
    219222        return self.perspective 
    220      
     223 
    221224    def on_perspective(self, event=None): 
    222225        """ 
     
    224227        We notify the parent window that the perspective 
    225228        has changed. 
    226          
     229 
    227230        :param event: menu event 
    228          
    229231        """ 
    230232        old_frame = None 
    231         tool_height = self.parent.get_toolbar_height() 
    232233        old_persp = self.parent.get_current_perspective() 
    233234        if old_persp != None: 
     
    236237        self.parent.set_current_perspective(self) 
    237238        self.parent.set_perspective(self.perspective) 
    238          
     239 
    239240        if self.frame != None: 
    240241            if old_frame != None: 
    241242                pos_x, pos_y = old_frame.GetPositionTuple() 
    242                 self.frame.SetPosition((pos_x, pos_y - tool_height)) 
     243                self.frame.SetPosition((pos_x, pos_y)) 
    243244            if not self.frame.IsShown(): 
    244245                self.frame.Show(True) 
    245          
    246          
     246 
    247247    def set_batch_selection(self, flag): 
    248248        """ 
     
    250250        """ 
    251251        self.batch_on = flag 
    252         self.on_batch_selection(self.batch_on)     
    253      
     252        self.on_batch_selection(self.batch_on) 
     253 
    254254    def on_batch_selection(self, flag): 
    255255        """ 
     
    262262        """ 
    263263        pass 
    264      
     264 
    265265    def set_default_perspective(self): 
    266266        """ 
    267267       Call back method that True to notify the parent that the current plug-in 
    268268       can be set as default  perspective. 
    269        when returning False, the plug-in is not candidate for an automatic  
     269       when returning False, the plug-in is not candidate for an automatic 
    270270       default perspective setting 
    271271        """ 
     
    273273            return True 
    274274        return False 
    275      
     275 
    276276    def set_state(self, state=None, datainfo=None):     
    277277        """ 
    278278        update state 
    279279        """ 
     280 
    280281    def set_data(self, data_list=None): 
    281282        """ 
    282283        receive a list of data and use it in the current perspective 
    283         
    284         """ 
     284        """ 
     285 
    285286    def set_theory(self, theory_list=None): 
    286287        """ 
    287         :param theory_list: list of information  
     288        :param theory_list: list of information 
    288289            related to available theory state 
    289290        """ 
    290291        msg = "%s plugin: does not support import theory" % str(self.sub_menu) 
    291         raise ValueError, msg  
    292      
     292        raise ValueError, msg 
     293 
    293294    def on_set_state_helper(self, event): 
    294295        """ 
    295296        update state 
    296297        """ 
    297      
     298 
Note: See TracChangeset for help on using the changeset viewer.