source: sasview/calculatorview/perspectives/calculator/calculator.py @ e847a42

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 e847a42 was e847a42, checked in by Gervaise Alina <gervyh@…>, 15 years ago

remove unused code

  • Property mode set to 100644
File size: 4.1 KB
Line 
1
2import wx
3import logging
4from sld_panel import SldPanel
5from sans.guicomm.events import NewPlotEvent, StatusEvent
6
7
8class Plugin:
9    """
10        This class defines the interface for a Plugin class
11        for calculator perspective
12    """
13   
14    def __init__(self, standalone=True):
15        """
16            Abstract class for gui_manager Plugins.
17        """
18        ## Plug-in name. It will appear on the application menu.
19        self.sub_menu = "Calculator"       
20       
21        ## Reference to the parent window. Filled by get_panels() below.
22        self.parent = None
23       
24        ## List of panels that you would like to open in AUI windows
25        #  for your plug-in. This defines your plug-in "perspective"
26        self.perspective = []
27        # Log startup
28        logging.info("Calculator plug-in started")   
29       
30    def populate_menu(self, id, owner):
31        """
32            Create and return the list of application menu
33            items for the plug-in.
34           
35            @param id: deprecated. Un-used.
36            @param parent: parent window
37            @return: plug-in menu
38        """
39        return []
40     
41    def get_panels(self, parent):
42        """
43            Create and return the list of wx.Panels for your plug-in.
44            Define the plug-in perspective.
45           
46            Panels should inherit from DefaultPanel defined below,
47            or should present the same interface. They must define
48            "window_caption" and "window_name".
49           
50            @param parent: parent window
51            @return: list of panels
52        """
53        ## Save a reference to the parent
54        self.parent = parent
55       
56        return []
57       
58   
59    def help(self, evt):
60        """
61            Show a general help dialog.
62            TODO: replace the text with a nice image
63            provide more hint on the SLD calculator
64        """
65        from help_panel import  HelpWindow
66        frame = HelpWindow(None, -1)   
67        frame.Show(True)
68     
69    def get_context_menu(self, graph=None):
70        """
71            This method is optional.
72       
73            When the context menu of a plot is rendered, the
74            get_context_menu method will be called to give you a
75            chance to add a menu item to the context menu.
76           
77            A ref to a Graph object is passed so that you can
78            investigate the plot content and decide whether you
79            need to add items to the context menu. 
80           
81            This method returns a list of menu items.
82            Each item is itself a list defining the text to
83            appear in the menu, a tool-tip help text, and a
84            call-back method.
85           
86            @param graph: the Graph object to which we attach the context menu
87            @return: a list of menu items with call-back function
88        """
89        return []   
90   
91    def get_perspective(self):
92        """
93            Get the list of panel names for this perspective
94        """
95        return self.perspective
96       
97   
98    def get_tools(self):
99        """
100            Returns a set of menu entries for tools
101        """
102        id = wx.NewId()
103        sld_help = "Provides computation related to Scattering Length density"
104        return [("SLD Calculator", sld_help, self.on_calculate_sld)]
105             
106    def on_calculate_sld(self, event):
107        """
108            Compute the scattering length density of molecula
109        """
110        from sld_panel import SldWindow
111        frame = SldWindow(base=self.parent)
112        frame.Show(True) 
113     
114       
115    def on_perspective(self, event):
116        """
117            Call back function for the perspective menu item.
118            We notify the parent window that the perspective
119            has changed.
120            @param event: menu event
121        """
122        self.parent.set_perspective(self.perspective)
123       
124   
125    def post_init(self):
126        """
127            Post initialization call back to close the loose ends
128        """
129        pass
130   
131 
132   
Note: See TracBrowser for help on using the repository browser.