source: sasview/calculatorview/perspectives/calculator/calculator.py @ 383eeaa

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

calculator gui created

  • Property mode set to 100644
File size: 4.2 KB
RevLine 
[427fa87]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    def help(self, evt):
66        """
67            Show a general help dialog.
68            TODO: replace the text with a nice image
69        """
70       
71        """
72            provide more hint on the SLD calculator
73        """
74        from help_panel import  HelpWindow
75        frame = HelpWindow(None, -1, pageToOpen="doc/sld_calculator_help.html")   
76        frame.Show(True)
77        name = "SLD_calculator"
78        if frame.rhelp.HasAnchor(name):
79            frame.rhelp.ScrollToAnchor(name)
80        else:
81           msg= "Cannot find SLD Calculator description "
82           msg +="Please.Search in the Help window"
83           wx.PostEvent(self.parent, StatusEvent(status = msg )) 
84       
85    def get_context_menu(self, graph=None):
86        """
87            This method is optional.
88       
89            When the context menu of a plot is rendered, the
90            get_context_menu method will be called to give you a
91            chance to add a menu item to the context menu.
92           
93            A ref to a Graph object is passed so that you can
94            investigate the plot content and decide whether you
95            need to add items to the context menu. 
96           
97            This method returns a list of menu items.
98            Each item is itself a list defining the text to
99            appear in the menu, a tool-tip help text, and a
100            call-back method.
101           
102            @param graph: the Graph object to which we attach the context menu
103            @return: a list of menu items with call-back function
104        """
105        return []   
106   
107    def get_perspective(self):
108        """
109            Get the list of panel names for this perspective
110        """
111        return self.perspective
112   
113    def on_perspective(self, event):
114        """
115            Call back function for the perspective menu item.
116            We notify the parent window that the perspective
117            has changed.
118            @param event: menu event
119        """
120        self.parent.set_perspective(self.perspective)
121   
122    def post_init(self):
123        """
124            Post initialization call back to close the loose ends
125        """
126        pass
Note: See TracBrowser for help on using the repository browser.