Changeset 7681bac in sasview
- Timestamp:
- Jun 20, 2008 9:04:17 AM (16 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- fbe6f71
- Parents:
- fbc51ef
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
rfc2b91a r7681bac 7 7 8 8 copyright 2008, University of Tennessee 9 10 How-to build an application using guiframe: 11 12 1- Write a main application script along the lines of dummyapp.py 13 2- Write a config script along the lines of config.py, and name it local_config.py 14 3- Write your plug-ins and place them in a directory called "perspectives". 15 - Look at local_perspectives/plotting for an example of a plug-in. 16 - A plug-in should define a class called Plugin. See abstract class below. 17 9 18 """ 10 19 import wx … … 33 42 import logging 34 43 44 class Plugin: 45 """ 46 This class defines the interface for a Plugin class 47 that can be used by the gui_manager. 48 49 Plug-ins should be placed in a sub-directory called "perspectives". 50 For example, a plug-in called Foo should be place in "perspectives/Foo". 51 That directory contains at least two files: 52 perspectives/Foo/__init.py contains two lines: 53 54 PLUGIN_ID = "Foo plug-in 1.0" 55 from Foo import * 56 57 perspectives/Foo/Foo.py contains the definition of the Plugin 58 class for the Foo plug-in. The interface of that Plugin class 59 should follow the interface of the class you are looking at. 60 """ 61 62 def __init__(self): 63 """ 64 Abstract class for gui_manager Plugins. 65 """ 66 ## Plug-in name. It will appear on the application menu. 67 self.sub_menu = "Plugin" 68 69 ## Reference to the parent window. Filled by get_panels() below. 70 self.parent = None 71 72 ## List of panels that you would like to open in AUI windows 73 # for your plug-in. This defines your plug-in "perspective" 74 self.perspective = [] 75 76 raise RuntimeError, "gui_manager.Plugin is an abstract class" 77 78 def populate_menu(self, id, parent): 79 """ 80 Create and return the list of application menu 81 items for the plug-in. 82 83 @param id: deprecated. Un-used. 84 @param parent: parent window 85 @return: plug-in menu 86 """ 87 import wx 88 # Create a menu 89 plug_menu = wx.Menu() 90 91 # Always get event IDs from wx 92 id = wx.NewId() 93 94 # Fill your menu 95 plug_menu.Append(id, '&Do something') 96 wx.EVT_MENU(owner, id, self._on_do_something) 97 98 # Returns the menu and a name for it. 99 return [(id, plug_menu, "name of the application menu")] 100 101 102 def get_panels(self, parent): 103 """ 104 Create and return the list of wx.Panels for your plug-in. 105 Define the plug-in perspective. 106 107 Panels should inherit from DefaultPanel defined below, 108 or should present the same interface. They must define 109 "window_caption" and "window_name". 110 111 @param parent: parent window 112 @return: list of panels 113 """ 114 ## Save a reference to the parent 115 self.parent = parent 116 117 # Define a panel 118 mypanel = DefaultPanel(self.parent, -1) 119 120 # If needed, add its name to the perspective list 121 self.perspective.append(self.control_panel.window_name) 122 123 # Return the list of panels 124 return [mypanel] 125 126 def get_context_menu(self, graph=None): 127 """ 128 This method is optional. 129 130 When the context menu of a plot is rendered, the 131 get_context_menu method will be called to give you a 132 chance to add a menu item to the context menu. 133 134 A ref to a Graph object is passed so that you can 135 investigate the plot content and decide whether you 136 need to add items to the context menu. 137 138 This method returns a list of menu items. 139 Each item is itself a list defining the text to 140 appear in the menu, a tool-tip help text, and a 141 call-back method. 142 143 @param graph: the Graph object to which we attach the context menu 144 @return: a list of menu items with call-back function 145 """ 146 return [["Menu text", 147 "Tool-tip help text", 148 self._on_context_do_something]] 149 150 def get_perspective(self): 151 """ 152 Get the list of panel names for this perspective 153 """ 154 return self.perspective 155 156 def on_perspective(self, event): 157 """ 158 Call back function for the perspective menu item. 159 We notify the parent window that the perspective 160 has changed. 161 @param event: menu event 162 """ 163 self.parent.set_perspective(self.perspective) 164 165 def post_init(self): 166 """ 167 Post initialization call back to close the loose ends 168 """ 169 pass 170 171 35 172 class ViewerFrame(wx.Frame): 36 173 """ … … 148 285 list = os.listdir(dir) 149 286 for item in list: 150 print item151 287 toks = os.path.splitext(os.path.basename(item)) 152 288 name = None … … 167 303 else: 168 304 (file, path, info) = imp.find_module(name, path) 169 print path170 305 module = imp.load_module( name, file, item, info ) 171 306 if hasattr(module, "PLUGIN_ID"):
Note: See TracChangeset
for help on using the changeset viewer.