- Timestamp:
- Feb 4, 2011 1:28:27 PM (14 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:
- 3f0351c6
- Parents:
- 27f3831
- Location:
- guiframe
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/gui_manager.py
rf036c692 ra45037aa 38 38 39 39 from sans.guiframe.events import EVT_STATUS 40 from sans.guiframe.events import EVT_ ADD_MANY_DATA40 from sans.guiframe.events import EVT_PANEL_ON_FOCUS 41 41 from sans.guiframe.events import StatusEvent 42 42 from sans.guiframe.events import NewPlotEvent … … 110 110 self._applications_menu = None 111 111 self._edit_menu = None 112 self._toolbar_menu = None 112 113 #tool bar 113 114 self._toolbar = None … … 141 142 self.Bind(EVT_STATUS, self._on_status_event) 142 143 #Register add extra data on the same panel event on load 143 self.Bind(EVT_ ADD_MANY_DATA, self.set_panel_on_focus)144 self.Bind(EVT_PANEL_ON_FOCUS, self.set_panel_on_focus) 144 145 145 146 def set_panel_on_focus(self, event): … … 150 151 """ 151 152 self.panel_on_focus = event.panel 153 panel_name = 'No panel on focus' 154 application_name = 'No Selected Application' 152 155 if self.panel_on_focus is not None and self._data_panel is not None: 153 name = self.panel_on_focus.window_name 154 self._data_panel.set_panel_on_focus() 155 if self._toolbar is not None: 156 self.update_button(self.panel_on_focus) 157 #update edit menu 158 self.enable_edit_menu() 156 panel_name = self.panel_on_focus.window_caption 157 self._data_panel.set_panel_on_focus(panel_name) 158 #update toolbar 159 self._update_toolbar_helper() 160 #update edit menu 161 self.enable_edit_menu() 162 print "set_panel_on_focus", event.panel.window_caption 159 163 160 164 def build_gui(self): … … 179 183 self.SetStatusBar(self.sb) 180 184 # Add panel 181 default_flag = wx.aui.AUI_MGR_DEFAULT | wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE185 default_flag = wx.aui.AUI_MGR_DEFAULT#| wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE 182 186 self._mgr = wx.aui.AuiManager(self, flags=default_flag) 183 187 … … 356 360 Name("default"). 357 361 Center(). 358 CloseButton(True). 362 CloseButton(False). 363 MinimizeButton(False). 359 364 # This is where we set the size of 360 365 # the application window … … 374 379 if style != GUIFRAME.MANAGER_ON: 375 380 self._mgr.GetPane(self.panels["data_panel"].window_name).Hide() 376 print "manager_on"377 381 else: 378 382 self._mgr.GetPane(self.panels["data_panel"].window_name).Show() … … 390 394 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 391 395 Name(p.window_name).Caption(p.window_caption). 392 CenterPane(). 396 #CenterPane(). 397 Center(). 398 CloseButton(False). 399 MinimizeButton(False). 393 400 MinSize(wx.Size(w, h)). 394 401 Hide()) … … 508 515 self._toolbar = GUIToolBar(self, -1) 509 516 self.SetToolBar(self._toolbar) 510 self._toolbar.update_button() 517 self._update_toolbar_helper() 518 #self._on_hide_toolbar(event=None) 519 520 def _update_toolbar_helper(self): 521 """ 522 """ 523 application_name = 'No Selected Application' 524 panel_name = 'No Panel on Focus' 525 self._toolbar.update_toolbar(self.panel_on_focus) 511 526 if self._current_perspective is not None: 512 name = self._current_perspective.sub_menu 513 self._toolbar.set_active_perspective(name) 514 527 application_name = self._current_perspective.sub_menu 528 if self.panel_on_focus is not None: 529 panel_name = self.panel_on_focus.window_caption 530 self._toolbar.update_button(application_name=application_name, 531 panel_name=panel_name) 532 self._toolbar.Realize() 533 515 534 def _add_menu_tool(self): 516 535 """ … … 635 654 wx.EVT_MENU(self, id, self.set_plotpanel_fixed) 636 655 id = wx.NewId() 656 style1 = self.__gui_style & GUIFRAME.MULTIPLE_APPLICATIONS 657 if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 658 id = wx.NewId() 659 self._toolbar_menu = preferences_menu.Append(id,'&Hide Toolbar', '') 660 wx.EVT_MENU(self, id, self._on_hide_toolbar) 637 661 self._window_menu.AppendSubMenu(preferences_menu,'&Preferences') 638 662 if self._window_menu.GetMenuItemCount() == 0: … … 809 833 self.show_data_panel(event=None) 810 834 835 def _on_hide_toolbar(self, event=None): 836 """ 837 hide or show toolbar 838 """ 839 if self._toolbar is None: 840 return 841 if self._toolbar.IsShown(): 842 if self._toolbar_menu is not None: 843 self._toolbar_menu.SetItemLabel('Show Toolbar') 844 self._toolbar.Hide() 845 else: 846 if self._toolbar_menu is not None: 847 self._toolbar_menu.SetItemLabel('Hide Toolbar') 848 self._toolbar.Show() 849 self._toolbar.Realize() 850 811 851 def _on_status_event(self, evt): 812 852 """ … … 1241 1281 if self._current_perspective is not None: 1242 1282 self._add_current_plugin_menu() 1283 for panel in self.panels.values(): 1284 if hasattr(panel, 'CENTER_PANE') and panel.CENTER_PANE: 1285 for name in self._current_perspective.get_perspective(): 1286 print "current",name.lower(),panel.window_name.lower(), name == panel.window_name 1287 if name == panel.window_name: 1288 panel.on_set_focus(event=None) 1289 print "panel", name, panel.window_name, panel.window_caption 1290 break 1291 1243 1292 name = self._current_perspective.sub_menu 1244 1293 if self._data_panel is not None: 1245 1294 self._data_panel.set_active_perspective(name) 1246 1295 self._check_applications_menu() 1247 # update tool bar1248 if self._toolbar is not None:1249 self._toolbar.set_active_perspective(name)1296 ##update tool bar 1297 #if self._toolbar is not None: 1298 # self._update_toolbar_helper() 1250 1299 1251 1300 def _check_applications_menu(self): … … 1341 1390 """ 1342 1391 if self.panel_on_focus is not None and self._edit_menu is not None: 1343 flag = panel_on_focus.get_undo_flag()1392 flag = self.panel_on_focus.get_undo_flag() 1344 1393 self._edit_menu.Enable(GUIFRAME_ID.UNDO_ID, flag) 1345 flag = panel_on_focus.get_redo_flag()1394 flag = self.panel_on_focus.get_redo_flag() 1346 1395 self._edit_menu.Enable(GUIFRAME_ID.REDO_ID, flag) 1347 flag = panel_on_focus.get_bookmark_flag()1396 flag = self.panel_on_focus.get_bookmark_flag() 1348 1397 self._edit_menu.Enable(GUIFRAME_ID.BOOKMARK_ID, flag) 1349 flag = panel_on_focus.get_save_flag()1398 flag = self.panel_on_focus.get_save_flag() 1350 1399 self._edit_menu.Enable(GUIFRAME_ID.SAVE_ID, flag) 1351 flag = panel_on_focus.get_print_flag()1400 flag = self.panel_on_focus.get_print_flag() 1352 1401 self._edit_menu.Enable(GUIFRAME_ID.PRINT_ID, flag) 1353 flag = panel_on_focus.get_prieview_flag()1402 flag = self.panel_on_focus.get_preview_flag() 1354 1403 self._edit_menu.Enable(GUIFRAME_ID.PREVIEW_ID, flag) 1355 flag = panel_on_focus.get_zoom_flag()1404 flag = self.panel_on_focus.get_zoom_flag() 1356 1405 self._edit_menu.Enable(GUIFRAME_ID.ZOOM_ID, flag) 1357 flag = panel_on_focus.get_zoom_in_flag()1406 flag = self.panel_on_focus.get_zoom_in_flag() 1358 1407 self._edit_menu.Enable(GUIFRAME_ID.ZOOM_IN_ID, flag) 1359 flag = panel_on_focus.get_zoom_out_flag()1408 flag = self.panel_on_focus.get_zoom_out_flag() 1360 1409 self._edit_menu.Enable(GUIFRAME_ID.ZOOM_OUT_ID, flag) 1361 flag = panel_on_focus.get_drag_flag()1410 flag = self.panel_on_focus.get_drag_flag() 1362 1411 self._edit_menu.Enable(GUIFRAME_ID.DRAG_ID, flag) 1363 flag = panel_on_focus.get_reset_flag()1412 flag = self.panel_on_focus.get_reset_flag() 1364 1413 self._edit_menu.Enable(GUIFRAME_ID.RESET_ID, flag) 1365 1414 else: -
guiframe/gui_toolbar.py
rf036c692 ra45037aa 56 56 size=tbar_size) 57 57 self.AddLabelTool(GUIFRAME_ID.REDO_ID, 'Redo', redo_bmp,shortHelp='Redo') 58 self.button = wx.Button(self, -1, 'Welcome') 59 self.button.SetForegroundColour('black') 60 self.button.SetBackgroundColour('#1874CD') 61 #self.button.Disable() 62 self.AddControl(self.button) 58 #add button for the current application 59 self.button_application = wx.Button(self, -1, 'Welcome') 60 self.button_application.SetForegroundColour('black') 61 self.button_application.SetBackgroundColour('#1874CD') 62 self.AddControl(self.button_application) 63 #add button for the panel on focus 64 self.button_panel = wx.Button(self, -1, 'No Panel') 65 self.button_panel.SetForegroundColour('black') 66 self.button_panel.SetBackgroundColour('#90EE90') 67 self.AddControl(self.button_panel) 63 68 64 69 self.SetToolBitmapSize(tbar_size) … … 92 97 id=GUIFRAME_ID.PRINT_ID) 93 98 94 def set_active_perspective(self,name=''):99 def update_button(self, application_name='', panel_name=''): 95 100 """ 96 101 """ 97 self.button.SetLabel(str(name)) 98 99 def update_button(self, panel=None): 102 self.button_application.SetLabel(str(application_name)) 103 self.button_panel.SetLabel(str(panel_name)) 104 print "update_button", application_name, panel_name 105 def update_toolbar(self, panel=None): 100 106 """ 101 107 """ -
guiframe/local_perspectives/plotting/Plotter1D.py
r7a67e075 ra45037aa 28 28 from sans.guiframe.events import ErrorDataEvent 29 29 from sans.guiframe.events import RemoveDataEvent 30 from sans.guiframe.events import AddManyDataEvent30 from sans.guiframe.events import PanelOnFocusEvent 31 31 from sans.guiframe.events import EVT_NEW_LOADED_DATA 32 32 from sans.guiframe.utils import PanelMenu … … 60 60 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 61 61 PlotPanel.__init__(self, parent, id=id, style=style, **kwargs) 62 PanelBase.__init__(self )62 PanelBase.__init__(self, parent) 63 63 ## Reference to the parent window 64 64 self.parent = parent … … 210 210 211 211 #post nd event to notify guiframe that this panel is on focus 212 wx.PostEvent(self.parent, AddManyDataEvent(panel=self))212 wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) 213 213 214 214 def _onRemove(self, event): -
guiframe/panel_base.py
rf036c692 ra45037aa 11 11 ################################################################################ 12 12 13 from sans.guiframe.events import PanelOnFocusEvent 14 import wx 13 15 14 16 class PanelBase: … … 24 26 #CENTER_PANE = True 25 27 26 def __init__(self ):28 def __init__(self, parent=None): 27 29 """ 28 30 Initialize some flag that Viewerframe used … … 42 44 self._drag_flag = False 43 45 self._reset_flag = False 44 46 self.parent = parent 47 self.Bind(wx.EVT_LEFT_DOWN, self.on_set_focus) 48 self.Bind(wx.EVT_TEXT_ENTER, self.on_set_focus) 49 self.Bind(wx.EVT_MIDDLE_DOWN, self.on_set_focus) 50 self.Bind(wx.EVT_RIGHT_DOWN, self.on_set_focus) 51 45 52 def _set_print_flag(self, flag=True): 46 53 """ … … 49 56 """ 50 57 self._print_flag = flag 58 self.on_set_focus(event=None) 51 59 52 60 def get_print_flag(self): … … 62 70 """ 63 71 self._undo_flag = flag 64 72 self.on_set_focus(event=None) 73 65 74 def get_undo_flag(self): 66 75 """ … … 75 84 """ 76 85 self._redo_flag = flag 77 86 self.on_set_focus(event=None) 87 78 88 def get_redo_flag(self): 79 89 """ … … 81 91 """ 82 92 return self._redo_flag 93 83 94 84 95 def _set_zoomed_in_flag(self, flag=True): … … 88 99 """ 89 100 self._zoom_in_flag = flag 101 self.on_set_focus(event=None) 102 90 103 91 104 def get_zoom_in_flag(self): … … 101 114 """ 102 115 self._zoom_out_flag = flag 116 self.on_set_focus(event=None) 103 117 104 118 def get_zoom_out_flag(self): … … 114 128 """ 115 129 self._zoom_flag = flag 116 130 self.on_set_focus(event=None) 131 117 132 def get_zoom_flag(self): 118 133 """ … … 127 142 """ 128 143 self._bookmark_flag = flag 129 144 self.on_set_focus(event=None) 145 130 146 def get_bookmark_flag(self): 131 147 """ … … 140 156 """ 141 157 self._preview_flag = flag 158 self.on_set_focus(event=None) 142 159 143 160 def get_preview_flag(self): … … 153 170 """ 154 171 self._save_flag = flag 155 172 self.on_set_focus(event=None) 173 156 174 def get_save_flag(self): 157 175 """ … … 166 184 """ 167 185 self._drag_flag = flag 168 186 169 187 def get_drag_flag(self): 170 188 """ … … 179 197 """ 180 198 self._reset_flag = flag 181 199 182 200 def get_reset_flag(self): 183 201 """ … … 227 245 if zoom mode is implemented 228 246 """ 229 def on_set_focus(self, event ):247 def on_set_focus(self, event=None): 230 248 """ 231 249 The derivative class is on focus if implemented 232 250 """ 251 if self.parent is not None: 252 print "on_set_focus", self.window_name, self.parent 253 wx.PostEvent(self.parent, PanelOnFocusEvent(panel=self)) 233 254 234 255 def get_data(self):
Note: See TracChangeset
for help on using the changeset viewer.