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

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 f5fda87 was a3498fa, checked in by Mathieu Doucet <doucetm@…>, 15 years ago

Minor clean up

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