source: sasview/guiframe/dummyapp.py @ cbf22e5

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

working on documentation

  • Property mode set to 100644
File size: 3.6 KB
Line 
1"""
2Dummy application.
3Allows the user to set an external data manager
4"""
5import gui_manager
6
7class TestPlugin(gui_manager.Plugin):
8   
9    def populate_menu(self, id, parent):
10        """
11        Create and return the list of application menu
12        items for the plug-in.
13       
14        :param id: deprecated. Un-used.
15        :param parent: parent window
16       
17        :return: plug-in menu
18       
19        """
20        import wx
21        # Create a menu
22        plug_menu = wx.Menu()
23
24        # Always get event IDs from wx
25        id = wx.NewId()
26       
27        # Fill your menu
28        plug_menu.Append(id, '&Do something')
29        def _on_do_something(event):
30            print "Do something"
31        wx.EVT_MENU(self.parent, id, _on_do_something)
32   
33        # Returns the menu and a name for it.
34        return [(id, plug_menu, "DummyApp")]   
35   
36    def get_panels(self, parent):
37        """
38        Create and return the list of wx.Panels for your plug-in.
39        Define the plug-in perspective.
40       
41        Panels should inherit from DefaultPanel defined below,
42        or should present the same interface. They must define
43        "window_caption" and "window_name".
44       
45        :param parent: parent window
46       
47        :return: list of panels
48       
49        """
50        ## Save a reference to the parent
51        self.parent = parent
52       
53        # Define a panel
54        defaultpanel = gui_manager.DefaultPanel(self.parent, -1)
55        defaultpanel.window_name = "Test"
56       
57        # If needed, add its name to the perspective list
58        self.perspective = [defaultpanel.window_name]
59
60        # Return the list of panels
61        return [defaultpanel]
62   
63    def get_tools(self):
64        """
65        Returns a set of menu entries for tools
66        """
67        def _test_dialog(event):
68            import wx
69            frame = wx.Dialog(None, -1, 'Test Tool')   
70            frame.Show(True)
71        return [["Tool 1", "This is an example tool", _test_dialog],
72                ["Tool 2", "This is another example tool", _test_dialog]]
73
74    def get_context_menu(self, graph=None):
75        """
76        This method is optional.
77   
78        When the context menu of a plot is rendered, the
79        get_context_menu method will be called to give you a
80        chance to add a menu item to the context menu.
81       
82        A ref to a Graph object is passed so that you can
83        investigate the plot content and decide whether you
84        need to add items to the context menu. 
85       
86        This method returns a list of menu items.
87        Each item is itself a list defining the text to
88        appear in the menu, a tool-tip help text, and a
89        call-back method.
90       
91        :param graph: the Graph object to which we attach the context menu
92       
93        :return: a list of menu items with call-back function
94        """
95        return [["Menu text", 
96                 "Tool-tip help text", 
97                 self._on_context_do_something]]   
98
99class SansView():
100   
101    def __init__(self):
102        """
103        Initialization
104        """
105        self.gui = gui_manager.ViewApp(0)
106       
107        fitting_plug = TestPlugin()
108        self.gui.add_perspective(fitting_plug)
109       
110        # Build the GUI
111        self.gui.build_gui()
112       
113        # Set the application manager for the GUI
114        self.gui.set_manager(self)
115       
116        # Start the main loop
117        self.gui.MainLoop() 
118
119if __name__ == "__main__": 
120    sansview = SansView()
Note: See TracBrowser for help on using the repository browser.