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

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

removing calculatorview as a perspective

  • Property mode set to 100644
File size: 4.4 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        # Define a panel
57        self.sld_panel= SldPanel(self.parent, -1)
58       
59        # If needed, add its name to the perspective list
60        #self.perspective.append(self.sld_panel.window_name)
61
62        # Return the list of panels
63        return [self.sld_panel]
64       
65   
66    def help(self, evt):
67        """
68            Show a general help dialog.
69            TODO: replace the text with a nice image
70            provide more hint on the SLD calculator
71        """
72        from help_panel import  HelpWindow
73        frame = HelpWindow(None, -1)   
74        frame.Show(True)
75     
76    def get_context_menu(self, graph=None):
77        """
78            This method is optional.
79       
80            When the context menu of a plot is rendered, the
81            get_context_menu method will be called to give you a
82            chance to add a menu item to the context menu.
83           
84            A ref to a Graph object is passed so that you can
85            investigate the plot content and decide whether you
86            need to add items to the context menu. 
87           
88            This method returns a list of menu items.
89            Each item is itself a list defining the text to
90            appear in the menu, a tool-tip help text, and a
91            call-back method.
92           
93            @param graph: the Graph object to which we attach the context menu
94            @return: a list of menu items with call-back function
95        """
96        return []   
97   
98    def get_perspective(self):
99        """
100            Get the list of panel names for this perspective
101        """
102        return self.perspective
103       
104   
105    def get_tools(self):
106        """
107            Returns a set of menu entries for tools
108        """
109        id = wx.NewId()
110        sld_help = "Provides computation related to Scattering Length density"
111        return [("SLD Calculator", sld_help, self.on_calculate_sld)]
112             
113    def on_calculate_sld(self, event):
114        """
115            Compute the scattering length density of molecula
116        """
117        from sld_panel import SldWindow
118        frame = SldWindow(base=self.parent)
119        frame.Show(True) 
120     
121       
122    def on_perspective(self, event):
123        """
124            Call back function for the perspective menu item.
125            We notify the parent window that the perspective
126            has changed.
127            @param event: menu event
128        """
129        self.parent.set_perspective(self.perspective)
130       
131   
132    def post_init(self):
133        """
134            Post initialization call back to close the loose ends
135        """
136        pass
137   
138 
139   
Note: See TracBrowser for help on using the repository browser.