- Timestamp:
- Jan 29, 2011 2:54:54 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:
- 584c4c4
- Parents:
- 3feed3e
- Location:
- guiframe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_manager.py
rf444b20 rc5e84fb 15 15 Data_manager make these new data available for all other perspectives. 16 16 """ 17 18 17 import logging 19 logging.basicConfig(level=logging.DEBUG, 20 format='%(asctime)s %(levelname)s %(message)s', 21 filename='sans_app.log', 22 filemode='w') 18 from sans.guiframe.data_state import DataState 23 19 24 20 class DataManager(object): … … 34 30 perspective 35 31 """ 36 self._selected_data = []32 self._selected_data = {} 37 33 self.stored_data = {} 38 34 self.message = "" … … 48 44 msg += "" 49 45 logging.info(msg) 50 self._selected_data.append(data) 51 self.stored_data[id] = data 46 data_state = DataState(data) 47 self._selected_data.append(data_state) 48 self.stored_data[id] = data_state 52 49 53 50 def set_auto_plot(self, flag=False): -
guiframe/data_panel.py
r3feed3e rc5e84fb 203 203 wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 204 204 205 self.tctrl_perspective = wx.StaticText(self, -1, ' Active Application')205 self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') 206 206 self.tctrl_perspective.SetToolTipString("Active Application") 207 207 self.tctrl_plotpanel = wx.StaticText(self, -1, 'Plot panel on focus') … … 275 275 """ 276 276 print "editing data" 277 277 278 def onContextMenu(self, event): 278 279 """ … … 281 282 # Skipping the save state functionality for release 0.9.0 282 283 #return 283 284 284 pos = event.GetPosition() 285 285 pos = self.ScreenToClient(pos) … … 290 290 """ 291 291 item = event.GetItem() 292 name = self.tree_ctrl.GetItemText(item)292 name = self.tree_ctrl.GetItemText(item) 293 293 294 294 def load_data_list(self, list): … … 408 408 """ 409 409 self.tctrl_perspective.SetLabel(str(name)) 410 410 411 411 def set_panel_on_focus(self, name): 412 412 """ … … 415 415 self.tctrl_plotpanel.SetLabel(str(name)) 416 416 417 def get_active_perspective(self):418 """419 """420 current_perspective = None421 if self.list_rb_perspectives:422 for item in self.list_rb_perspectives:423 if item.GetValue():424 current_perspective = item.GetLabelText()425 return current_perspective426 427 417 def post_helper(self, plot=False): 428 418 """ -
guiframe/gui_manager.py
r3feed3e rc5e84fb 95 95 self._data_manager = DataManager() 96 96 self._data_panel = DataPanel(parent=self) 97 97 98 98 #add current perpsective 99 99 self._current_perspective = None … … 106 106 self._window_menu = None 107 107 self._window_menu = None 108 self._help = None109 108 self._help_menu = None 109 self._tool_menu = None 110 110 ## Find plug-ins 111 111 # Modify this so that we can specify the directory to look into … … 114 114 self.plugins += self._get_local_plugins() 115 115 self.plugins += self._find_plugins() 116 print "self.plugins", self.plugins117 116 ## List of panels 118 117 self.panels = {} … … 169 168 # Load panels 170 169 self._load_panels() 170 self.set_default_perspective() 171 171 self._mgr.Update() 172 172 … … 430 430 MinimizeButton(). 431 431 Resizable(True). 432 # Use a large best size to make sure the AUI manager433 # takes all the available space432 # Use a large best size to make sure the AUI 433 # manager takes all the available space 434 434 BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 435 print "GUIFRAME.FIXED_PANEL"436 435 self._popup_fixed_panel(p) 437 436 438 437 elif style2 in GUIFRAME.FLOATING_PANEL: 439 print "GUIFRAME.Floating_PANEL"440 438 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 441 439 Name(windowname).Caption(caption). 442 440 MinimizeButton(). 443 441 Resizable(True). 444 # Use a large best size to make sure the AUI manager445 # takes all the available space442 # Use a large best size to make sure the AUI 443 # manager takes all the available space 446 444 BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 447 445 self._popup_floating_panel(p) … … 478 476 self._add_menu_data() 479 477 self._add_menu_application() 478 self._add_current_plugin_menu() 479 self._add_menu_tool() 480 480 self._add_menu_window() 481 # Tools menu 482 # Go through plug-ins and find tools to populate the tools menu 483 toolsmenu = None 484 for item in self.plugins: 485 if hasattr(item, "get_tools"): 486 for tool in item.get_tools(): 487 # Only create a menu if we have at least one tool 488 if toolsmenu is None: 489 toolsmenu = wx.Menu() 490 id = wx.NewId() 491 toolsmenu.Append(id, tool[0], tool[1]) 492 wx.EVT_MENU(self, id, tool[2]) 493 if toolsmenu is not None: 494 self._menubar.Append(toolsmenu, '&Tools') 495 496 # Help menu 497 helpmenu = wx.Menu() 498 # add the welcome panel menu item 499 if self.defaultPanel is not None: 500 id = wx.NewId() 501 helpmenu.Append(id, '&Welcome', '') 502 helpmenu.AppendSeparator() 503 wx.EVT_MENU(self, id, self.show_welcome_panel) 504 # Look for help item in plug-ins 505 for item in self.plugins: 506 if hasattr(item, "help"): 507 id = wx.NewId() 508 helpmenu.Append(id,'&%s help' % item.sub_menu, '') 509 wx.EVT_MENU(self, id, item.help) 510 if config._do_aboutbox: 511 id = wx.NewId() 512 helpmenu.Append(id,'&About', 'Software information') 513 wx.EVT_MENU(self, id, self._onAbout) 514 515 # Checking for updates needs major refactoring to work with py2exe 516 # We need to make sure it doesn't hang the application if the server 517 # is not up. We also need to make sure there's a proper executable to 518 # run if we spawn a new background process. 519 #id = wx.NewId() 520 #helpmenu.Append(id,'&Check for update', 521 #'Check for the latest version of %s' % config.__appname__) 522 #wx.EVT_MENU(self, id, self._check_update) 523 524 # Look for plug-in menus 481 self._add_help_menu() 482 self.SetMenuBar(self._menubar) 483 484 def _add_menu_tool(self): 485 """ 486 Tools menu 487 Go through plug-ins and find tools to populate the tools menu 488 """ 489 style = self.__gui_style & GUIFRAME.TOOL_ON 490 if style == GUIFRAME.TOOL_ON: 491 self._tool_menu = None 492 for item in self.plugins: 493 if hasattr(item, "get_tools"): 494 for tool in item.get_tools(): 495 # Only create a menu if we have at least one tool 496 if self._tool_menu is None: 497 self._tool_menu = wx.Menu() 498 id = wx.NewId() 499 self._tool_menu.Append(id, tool[0], tool[1]) 500 wx.EVT_MENU(self, id, tool[2]) 501 if self._tool_menu is not None: 502 self._menubar.Append(self._tool_menu, '&Tools') 503 504 def _add_current_plugin_menu(self): 505 """ 506 add current plugin menu 507 """ 508 # Look for plug-in menus 525 509 # Add available plug-in sub-menus. 526 510 for item in self.plugins: … … 530 514 self._menubar.Append(menu, name) 531 515 532 self._menubar.Append(helpmenu, '&Help') 533 self.SetMenuBar(self._menubar) 534 516 def _add_help_menu(self): 517 """ 518 add help menu 519 """ 520 # Help menu 521 self._help_menu = wx.Menu() 522 # add the welcome panel menu item 523 if self.defaultPanel is not None: 524 id = wx.NewId() 525 self._help_menu.Append(id, '&Welcome', '') 526 self._help_menu.AppendSeparator() 527 wx.EVT_MENU(self, id, self.show_welcome_panel) 528 # Look for help item in plug-ins 529 for item in self.plugins: 530 if hasattr(item, "help"): 531 id = wx.NewId() 532 self._help_menu.Append(id,'&%s help' % item.sub_menu, '') 533 wx.EVT_MENU(self, id, item.help) 534 if config._do_aboutbox: 535 id = wx.NewId() 536 self._help_menu.Append(id,'&About', 'Software information') 537 wx.EVT_MENU(self, id, self._onAbout) 538 539 # Checking for updates needs major refactoring to work with py2exe 540 # We need to make sure it doesn't hang the application if the server 541 # is not up. We also need to make sure there's a proper executable to 542 # run if we spawn a new background process. 543 #id = wx.NewId() 544 #self._help_menu.Append(id,'&Check for update', 545 #'Check for the latest version of %s' % config.__appname__) 546 #wx.EVT_MENU(self, id, self._check_update) 547 self._menubar.Append(self._help_menu, '&Help') 548 535 549 def _add_menu_window(self): 536 550 """ … … 553 567 self._window_menu.AppendSeparator() 554 568 self._menubar.Append(self._window_menu, '&Window') 555 if self.defaultPanel is not None : 556 id = wx.NewId() 557 self._window_menu.Append(id,'&Welcome', '') 558 559 wx.EVT_MENU(self, id, self.show_welcome_panel) 569 560 570 style = self.__gui_style & GUIFRAME.MANAGER_ON 561 571 if style == GUIFRAME.MANAGER_ON: … … 619 629 # File menu 620 630 self._filemenu = wx.Menu() 621 622 631 # some menu of plugin to be seen under file menu 623 632 self._populate_file_menu() 624 625 633 id = wx.NewId() 626 634 self._filemenu.Append(id, '&Save state into File', 627 635 'Save project as a SansView (svs) file') 628 636 wx.EVT_MENU(self, id, self._on_save) 629 #self.__filemenu.AppendSeparator()630 631 637 id = wx.NewId() 632 638 self._filemenu.Append(id, '&Quit', 'Exit') 633 639 wx.EVT_MENU(self, id, self.Close) 634 635 640 # Add sub menus 636 641 self._menubar.Append(self._filemenu, '&File') … … 712 717 return 713 718 for id in self.panels.keys(): 714 if self._mgr.GetPane(self.panels[id].window_name).IsShown(): 719 if id == 'default': 720 # Show default panel 721 if not self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 722 self._mgr.GetPane(self.panels["default"].window_name).Show(True) 723 elif id == "data_panel": 724 flag = self._mgr.GetPane(self.panels["data_panel"].window_name).IsShown() 725 self._mgr.GetPane(self.panels["data_panel"].window_name).Show(flag) 726 else: 727 self._mgr.GetPane(self.panels[id].window_name).IsShown() 715 728 self._mgr.GetPane(self.panels[id].window_name).Hide() 716 # Show default panel717 if not self._mgr.GetPane(self.panels["default"].window_name).IsShown():718 self._mgr.GetPane(self.panels["default"].window_name).Show()719 720 729 self._mgr.Update() 721 730 722 731 def show_panel(self, uid): 723 732 """ … … 950 959 if hasattr(item, "set_default_perspective"): 951 960 if item.set_default_perspective(): 952 self._current_perspective = item953 961 item.on_perspective(event=None) 954 962 return … … 1008 1016 pane.Show(True) 1009 1017 self._mgr.Update() 1010 1011 def show_welcome_panel(self, event): 1012 """ 1013 show welcome panel 1014 """ 1015 1018 1016 1019 def add_data(self, data_list): 1017 1020 """ … … 1028 1031 if style == GUIFRAME.MANAGER_ON: 1029 1032 if self._data_panel is not None: 1033 data_state = self._data_manager.get_selected_data() 1034 self._data_panel.load_data_list(data_state) 1030 1035 self._mgr.GetPane(self._data_panel.window_name).Show(True) 1031 1036 #wait for button press from the data panel to send data … … 1034 1039 style = self.__gui_style & GUIFRAME.SINGLE_APPLICATION 1035 1040 if style == GUIFRAME.SINGLE_APPLICATION: 1036 if self._current_perspective is not None: 1037 try: 1038 self._current_perspective.set_data(data_list) 1039 except: 1040 msg = str(sys.exc_value) 1041 wx.PostEvent(self, StatusEvent(status=msg, 1042 info="error")) 1043 else: 1044 msg = "Guiframe does not have a current perspective" 1045 logging.info(msg) 1046 1047 1041 self.set_data(data_list) 1042 1043 def set_data_from_panel(self, data_id): 1044 """ 1045 receive a list of data key retreive the data from data manager and set 1046 then to the current perspective 1047 """ 1048 1049 def set_data(self, data_list): 1050 """ 1051 set data to current perspective 1052 """ 1053 if self._current_perspective is not None: 1054 try: 1055 self._current_perspective.set_data(data_list) 1056 except: 1057 msg = str(sys.exc_value) 1058 wx.PostEvent(self, StatusEvent(status=msg, info="error")) 1059 else: 1060 msg = "Guiframe does not have a current perspective" 1061 logging.info(msg) 1062 1048 1063 def plot_data(self, data_list): 1049 1064 """ … … 1060 1075 """ 1061 1076 self._current_perspective = perspective 1062 1077 name = "No current Application selected" 1078 if self._current_perspective is not None and \ 1079 self._data_panel is not None: 1080 name = self._current_perspective.sub_menu 1081 self._data_panel.set_active_perspective(name) 1082 1063 1083 def set_plotpanel_floating(self, event): 1064 1084 """
Note: See TracChangeset
for help on using the changeset viewer.