source: sasview/guiframe/plugin_base.py @ c958e30

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since c958e30 was 60fff67, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on remove data

  • Property mode set to 100644
File size: 7.1 KB
Line 
1################################################################################
2#This software was developed by the University of Tennessee as part of the
3#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4#project funded by the US National Science Foundation.
5#
6#See the license text in license.txt
7#
8#copyright 2008, University of Tennessee
9################################################################################
10 
11class PluginBase:
12    """
13    This class defines the interface for a Plugin class
14    that can be used by the gui_manager.
15   
16    Plug-ins should be placed in a sub-directory called "perspectives".
17    For example, a plug-in called Foo should be place in "perspectives/Foo".
18    That directory contains at least two files:
19        perspectives/Foo/__init__.py contains two lines:
20       
21            PLUGIN_ID = "Foo plug-in 1.0"
22            from Foo import *
23           
24        perspectives/Foo/Foo.py contains the definition of the Plugin
25        class for the Foo plug-in. The interface of that Plugin class
26        should follow the interface of the class you are looking at.
27       
28    See dummyapp.py for a plugin example.
29    """
30   
31    def __init__(self, name="Test_plugin", standalone=True):
32        """
33            Abstract class for gui_manager Plugins.
34        """
35        # Define if the plugin is local to Viewerframe  and always active
36        self._always_active = False
37        ## Plug-in name. It will appear on the application menu.
38        self.sub_menu = name     
39        #standalone flag
40        self.standalone = standalone
41        ## Reference to the parent window. Filled by get_panels() below.
42        self.parent = None
43        #plugin state reader
44        self.state_reader = None 
45        self._extensions = ''
46        ## List of panels that you would like to open in AUI windows
47        #  for your plug-in. This defines your plug-in "perspective"
48        self.perspective = []
49       
50    def clear_panel(self):
51        """
52        clear all related panels
53        """
54    def get_extensions(self):
55        """
56        return state reader and its extensions
57        """
58        return self.state_reader, self._extensions
59   
60    def can_load_data(self):
61        """
62        if return True, then call handler to laod data
63        """
64        return False
65   
66    def use_data(self):
67        """
68        return True if these plugin use data
69        """
70        return True
71   
72    def is_in_use(self, data_id):
73        """
74        get a  data id a list of data name if data data is
75         currently used by the plugin and the name of the plugin
76       
77        data_name = 'None'
78        in_use = False
79        example [(data_name, self.sub_menu)]
80        """
81        return []
82   
83    def delete_data(self, data_id):
84        """
85        Delete all references of data which id are in data_list.
86        """
87       
88    def load_data(self, event):
89        """
90        Load  data
91        """
92        raise NotImplemented
93 
94    def load_folder(self, event):
95        """
96        Load entire folder
97        """
98        raise NotImplemented 
99   
100    def set_is_active(self, active=False):
101        """
102        """
103        self._always_active = active
104       
105    def is_always_active(self):
106        """
107        return True is this plugin is always active and it is local to guiframe
108        even if the user is switching between perspectives
109        """
110        return self._always_active
111   
112    def populate_file_menu(self):
113        """
114        Append menu item under file menu item of the frame
115        """
116        return []
117   
118    def populate_menu(self, parent):
119        """
120        Create and return the list of application menu
121        items for the plug-in.
122       
123        :param parent: parent window
124       
125        :return: plug-in menu
126       
127        """
128        return []
129   
130    def get_panels(self, parent):
131        """
132        Create and return the list of wx.Panels for your plug-in.
133        Define the plug-in perspective.
134       
135        Panels should inherit from DefaultPanel defined below,
136        or should present the same interface. They must define
137        "window_caption" and "window_name".
138       
139        :param parent: parent window
140       
141        :return: list of panels
142       
143        """
144        ## Save a reference to the parent
145        self.parent = parent
146       
147        # Return the list of panels
148        return []
149   
150 
151    def get_tools(self):
152        """
153        Returns a set of menu entries for tools
154        """
155        return []
156       
157   
158    def get_context_menu(self, plotpanel=None):
159        """
160        This method is optional.
161   
162        When the context menu of a plot is rendered, the
163        get_context_menu method will be called to give you a
164        chance to add a menu item to the context menu.
165       
166        A ref to a plotpanel object is passed so that you can
167        investigate the plot content and decide whether you
168        need to add items to the context menu. 
169       
170        This method returns a list of menu items.
171        Each item is itself a list defining the text to
172        appear in the menu, a tool-tip help text, and a
173        call-back method.
174       
175        :param graph: the Graph object to which we attach the context menu
176       
177        :return: a list of menu items with call-back function
178       
179        """
180        return []
181   
182    def get_perspective(self):
183        """
184        Get the list of panel names for this perspective
185        """
186        return self.perspective
187   
188    def on_perspective(self, event=None):
189        """
190        Call back function for the perspective menu item.
191        We notify the parent window that the perspective
192        has changed.
193       
194        :param event: menu event
195       
196        """
197        self.parent.set_current_perspective(self)
198        self.parent.set_perspective(self.perspective)
199   
200    def post_init(self):
201        """
202        Post initialization call back to close the loose ends
203        """
204        pass
205   
206    def set_default_perspective(self):
207        """
208       Call back method that True to notify the parent that the current plug-in
209       can be set as default  perspective.
210       when returning False, the plug-in is not candidate for an automatic
211       default perspective setting
212        """
213        if self.standalone:
214            return True
215        return False
216   
217    def set_state(self, state=None, datainfo=None):   
218        """
219        update state
220        """
221    def set_data(self, data_list=None):
222        """
223        receive a list of data and use it in the current perspective
224       
225        """
226    def set_theory(self, theory_list=None):
227        """
228        :param theory_list: list of information
229            related to available theory state
230        """
231        msg = "%s plugin: does not support import theory" % str(self.sub_menu)
232        raise ValueError, msg
233   
234    def on_set_state_helper(self, event):
235        """
236        update state
237        """
238   
Note: See TracBrowser for help on using the repository browser.