source: sasview/src/sas/sasgui/guiframe/dummyapp.py @ 2fe78566

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.2ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 2fe78566 was b080ba8, checked in by smk78, 9 years ago

Changed ViewApp? to SasViewApp? to fix Sphinx doc build errors.

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