Changeset ae84427 in sasview for sansguiframe/src
- Timestamp:
- Apr 20, 2013 7:14:41 PM (12 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:
- ba152f1
- Parents:
- d4895dd
- Location:
- sansguiframe/src/sans/guiframe
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/data_panel.py
r318b5bbb rae84427 142 142 self._default_save_location = None 143 143 self.all_data1d = True 144 self.parent = parent 145 self.manager = manager 144 self.parent = parent.parent 145 self._manager = manager 146 self.frame = None 146 147 if list is None: 147 148 list = [] … … 1008 1009 self.enable_append() 1009 1010 self.enable_remove_plot() 1010 1011 1012 def set_plot_unfocus(self): 1013 """ 1014 Unfocus plot 1015 """ 1016 return 1017 1011 1018 def _on_perspective_selection(self, event=None): 1012 1019 """ … … 1047 1054 action="delete")) 1048 1055 self.enable_remove_plot() 1056 1057 def set_frame(self, frame): 1058 """ 1059 """ 1060 self.frame = frame 1061 1062 def get_frame(self): 1063 """ 1064 """ 1065 return self.frame 1066 1067 def set_schedule_full_draw(self, panel=None, func='del'): 1068 """ 1069 Send full draw to guimanager 1070 """ 1071 self.parent.set_schedule_full_draw(panel, func) 1049 1072 1050 1073 def enable_remove_plot(self): … … 1261 1284 temp.append(data) 1262 1285 return temp 1263 1286 1264 1287 class DataFrame(wx.Frame): 1265 1288 """ … … 1282 1305 self.parent = parent 1283 1306 self.owner = owner 1284 self. manager = manager1307 self._manager = manager 1285 1308 self.panel = DataPanel(parent=self, 1286 #size=size,1309 manager=manager, 1287 1310 list_of_perspective=list_of_perspective) 1288 1311 -
sansguiframe/src/sans/guiframe/gui_manager.py
r592cd678 rae84427 7 7 #project funded by the US National Science Foundation. 8 8 # 9 #See the license text in license.txt 9 #See the license text in license.txtz 10 10 # 11 11 #copyright 2008, University of Tennessee … … 192 192 IS_WIN = True 193 193 CLOSE_SHOW = True 194 TIME_FACTOR = 1194 TIME_FACTOR = 2 195 195 NOT_SO_GRAPH_LIST = ["BoxSum"] 196 196 if sys.platform.count("win32")==0: … … 201 201 CLOSE_SHOW = False 202 202 203 class ViewerFrame(wx. Frame):203 class ViewerFrame(wx.MDIParentFrame): 204 204 """ 205 205 Main application frame … … 215 215 """ 216 216 217 wx. Frame.__init__(self, parent=parent, title=title, pos=pos, size=size)217 wx.MDIParentFrame.__init__(self, parent=parent, title=title, pos=pos, size=size) 218 218 # title 219 219 self.title = title 220 # Preferred window size221 self._window_width, self._window_height = size222 220 self.__gui_style = gui_style 223 221 path = os.path.dirname(__file__) … … 292 290 #control_panel on focus 293 291 self.cpanel_on_focus = None 292 294 293 self.loader = Loader() 295 294 #data manager … … 297 296 from sans.guiframe.data_manager import DataManager 298 297 self._data_manager = DataManager() 299 self._data_panel = DataPanel(parent=self)298 self._data_panel = None#DataPanel(parent=self) 300 299 if self.panel_on_focus is not None: 301 300 self._data_panel.set_panel_on_focus( … … 312 311 self.on_batch_selection(event=None) 313 312 self.add_icon() 313 314 314 # Register the close event so it calls our own method 315 315 wx.EVT_CLOSE(self, self.WindowClose) … … 324 324 self.Bind(EVT_CATEGORY, self.on_change_categories) 325 325 self.setup_custom_conf() 326 # Preferred window size 327 self._window_width, self._window_height = size 326 328 327 329 def add_icon(self): … … 345 347 except: 346 348 pass 347 349 350 def get_client_size(self): 351 """ 352 return client size tuple 353 """ 354 width, height = self.GetClientSizeTuple() 355 height -= 45 356 # Adjust toolbar height 357 toolbar = self.GetToolBar() 358 if toolbar != None: 359 _, tb_h = toolbar.GetSizeTuple() 360 height -= tb_h 361 return width, height 362 348 363 def on_change_categories(self, evt): 349 364 # ILL … … 597 612 598 613 plugin.on_perspective(event=None) 614 frame = plugin.get_frame() 615 frame.Show(True) 599 616 #self._check_applications_menu() 600 break 617 #break 618 else: 619 frame = plugin.get_frame() 620 frame.Show(False) 601 621 except: 602 622 pass … … 651 671 #Disable save application if the current panel is in batch mode 652 672 flag = self.panel_on_focus.get_save_flag() 653 self._save_appl_menu.Enable(flag) 673 if self._save_appl_menu != None: 674 self._save_appl_menu.Enable(flag) 654 675 655 676 if self.panel_on_focus not in self.plot_panels.values(): … … 665 686 #update edit menu 666 687 self.enable_edit_menu() 667 688 668 689 def disable_app_menu(self, p_panel=None): 669 690 """ 670 691 Disables all menus in the menubar 671 692 """ 672 if p_panel == None: 673 return 674 p_name = p_panel.window_name 675 enable = not self._mgr.GetPane(p_name).IsMaximized() 676 if self._data_panel is not None: 677 self._data_panel.disable_app_combo(enable) 678 if self._menubar is not None: 679 for menu, _ in self._menubar.GetMenus(): 680 for items in menu.GetMenuItems(): 681 items.Enable(enable) 682 c_panel = self.cpanel_on_focus 683 # disable depending on the save_app flag 684 self._save_appl_menu.Enable(c_panel.get_save_flag()) 685 if not enable: 686 if self._toolbar is not None: 687 self._toolbar.update_toolbar(None) 688 p_panel.on_set_focus(None) 689 else: 690 self._toolbar.update_toolbar(c_panel) 693 return 691 694 692 695 def set_panel_on_focus_helper(self): … … 695 698 """ 696 699 ID = self.panel_on_focus.uid 697 self._data_panel.set_panel_on_focus(ID) 700 if self._data_panel != None: 701 self._data_panel.set_panel_on_focus(ID) 698 702 #update combo 699 703 if self.panel_on_focus in self.plot_panels.values(): … … 707 711 cpanel.on_tap_focus() 708 712 self.cpanel_on_focus = self.panel_on_focus 709 713 710 714 def reset_bookmark_menu(self, panel): 711 715 """ … … 758 762 self._setup_extra_custom() 759 763 self._check_update(None) 760 764 761 765 def _setup_extra_custom(self): 762 766 """ … … 781 785 self.SetStatusBar(self.sb) 782 786 # Add panel 783 default_flag = wx.aui.AUI_MGR_DEFAULT#| wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE784 self._mgr = wx.aui.AuiManager(self, flags=default_flag)785 self._mgr.SetDockSizeConstraint(0.5, 0.5)787 #default_flag = wx.aui.AUI_MGR_DEFAULT#| wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE 788 #self._mgr = wx.aui.AuiManager(self, flags=default_flag) 789 #self._mgr.SetDockSizeConstraint(0.5, 0.5) 786 790 # Load panels 787 791 self._load_panels() 788 792 self.set_default_perspective() 789 self._mgr.Update()793 #self._mgr.Update() 790 794 791 795 def SetStatusText(self, *args, **kwds): … … 906 910 except: 907 911 msg = "ViewerFrame._find_plugins: %s" % sys.exc_value 908 #print msg909 912 logging.error(msg) 910 913 finally: … … 925 928 926 929 """ 927 self.defaultPanel = panel_class(self, -1, style=wx.RAISED_BORDER) 930 win = MDIFrame(self, None, 'None', (100, 200)) 931 self.defaultPanel = panel_class(win, -1, style=wx.RAISED_BORDER) 932 win.set_panel(self.defaultPanel) 933 self.defaultPanel.set_frame(win) 934 #win.EnableCloseButton(False) 935 win.Show(False) 928 936 929 937 def _get_panels_size(self, p): … … 932 940 get the proper panel width and height 933 941 """ 934 ## Check and set the size 942 self._window_width, self._window_height = self.get_client_size() 943 ## Default size 935 944 if DATAPANEL_WIDTH < 0: 936 panel_width = int(self._window_width * 0.2 2)945 panel_width = int(self._window_width * 0.25) 937 946 else: 938 947 panel_width = DATAPANEL_WIDTH 939 panel_height = int(self._window_height * 0.9)948 panel_height = int(self._window_height) 940 949 style = self.__gui_style & (GUIFRAME.MANAGER_ON) 941 950 if self._data_panel is not None and (p == self._data_panel): 942 951 return panel_width, panel_height 943 952 if hasattr(p, "CENTER_PANE") and p.CENTER_PANE: 944 style = self.__gui_style & (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON)945 if style == (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON):946 panel_width = self._window_width - panel_width953 #style = self.__gui_style & (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON) 954 #if style == (GUIFRAME.PLOTTING_ON|GUIFRAME.MANAGER_ON): 955 panel_width = self._window_width * 0.45 947 956 return panel_width, panel_height 957 elif p == self.defaultPanel: 958 return self._window_width, panel_height 959 #total_width = panel_width + self._window_width - 2.3 * panel_width 948 960 return panel_width, panel_height 949 961 … … 952 964 Load all panels in the panels directory 953 965 """ 954 955 966 # Look for plug-in panels 956 967 panels = [] … … 963 974 # It also sets the size of the application windows 964 975 #TODO: Use this for splash screen 965 if self.defaultPanel is None:966 self.defaultPanel = DefaultPanel(self, -1, style=wx.RAISED_BORDER)976 #if self.defaultPanel is None: 977 # self.defaultPanel = DefaultPanel(self, -1, style=wx.RAISED_BORDER) 967 978 # add a blank default panel always present 968 979 self.panels["default"] = self.defaultPanel 980 w, h = self._get_panels_size(self.defaultPanel) 981 #win = MDIFrame(self, DefaultPanel, "default", 982 # (self._window_width, self._window_height)) 983 #win.set_panel(self.defaultPanel) 984 #self.defaultPanel.set_frame(win) 985 frame = self.defaultPanel.get_frame() 986 frame.SetSize((self._window_width, self._window_height)) 987 frame.Show(True) 988 """ 969 989 self._mgr.AddPane(self.defaultPanel, wx.aui.AuiPaneInfo(). 970 990 Name("default"). … … 975 995 self._window_height)). 976 996 Show()) 977 997 """ 978 998 #add data panel 999 1000 w, h = self._get_panels_size(self._data_panel) 1001 win = MDIFrame(self, None, 'None', (w,h)) 1002 self._data_panel = DataPanel(parent=win) 1003 win.set_panel(self._data_panel) 1004 win.EnableCloseButton(False) 979 1005 self.panels["data_panel"] = self._data_panel 980 w, h = self._get_panels_size(self._data_panel) 981 self._mgr.AddPane(self._data_panel, wx.aui.AuiPaneInfo(). 982 Name(self._data_panel.window_name). 983 Caption(self._data_panel.window_caption). 984 Left(). 985 CloseButton(CLOSE_SHOW). 986 TopDockable(False). 987 BottomDockable(False). 988 LeftDockable(True). 989 RightDockable(False). 990 BestSize(wx.Size(w, h)). 991 Hide()) 992 1006 self._data_panel.set_frame(win) 993 1007 style = self.__gui_style & GUIFRAME.MANAGER_ON 994 data_pane = self._mgr.GetPane(self.panels["data_panel"].window_name)995 1008 if style != GUIFRAME.MANAGER_ON: 996 data_pane.Hide()1009 flag = False 997 1010 else: 998 data_pane.Show() 999 1011 flag = True 1012 win.Show(flag) 1013 d_panel_width = w 1000 1014 # Add the panels to the AUI manager 1001 1015 for panel_class in panels: 1002 p = panel_class1016 frame = panel_class.get_frame() 1003 1017 id = wx.NewId() 1004 1018 # Check whether we need to put this panel 1005 1019 # in the center pane 1006 if hasattr(p, "CENTER_PANE") and p.CENTER_PANE: 1007 w, h = self._get_panels_size(p) 1008 if p.CENTER_PANE: 1009 self.panels[str(id)] = p 1020 1021 if hasattr(panel_class, "CENTER_PANE") and panel_class.CENTER_PANE: 1022 w, h = self._get_panels_size(panel_class) 1023 if panel_class.CENTER_PANE: 1024 self.panels[str(id)] = panel_class 1025 _, pos_y = frame.GetPositionTuple() 1026 frame.SetPosition((d_panel_width, pos_y)) 1027 frame.SetSize((w, h)) 1028 frame.Show(False) 1029 """ 1010 1030 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 1011 1031 Name(p.window_name). … … 1014 1034 CloseButton(False). 1015 1035 Hide()) 1036 """ 1016 1037 else: 1017 self.panels[str(id)] = p 1038 self.panels[str(id)] = panel_class 1039 frame.SetSize((w, h)) 1040 frame.Show(False) 1041 #win = MDIFrame(self, p, p.window_name, (w, h)) 1042 #win.set_panel(p) 1043 """ 1018 1044 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). 1019 1045 Name(p.window_name).Caption(p.window_caption). … … 1026 1052 MinimizeButton(). 1027 1053 Hide()) 1028 1054 """ 1055 #if frame != None: 1056 # frame.EnableCloseButton(False) 1057 1029 1058 def update_data(self, prev_data, new_data): 1030 1059 """ … … 1108 1137 delete it. 1109 1138 """ 1110 panel = event.GetPane() 1111 if panel.IsMaximized(): 1112 self._mgr.RestoreMaximizedPane() 1139 frame = event.GetEventObject() 1140 #panel = frame.panel 1141 #if panel.IsMaximized(): 1142 # self._mgr.RestoreMaximizedPane() 1113 1143 for ID in self.plot_panels.keys(): 1114 if self.plot_panels[ID].window_name == panel.name:1144 if self.plot_panels[ID].window_name == frame.name: 1115 1145 self.disable_app_menu(self.plot_panels[ID]) 1116 1146 self.delete_panel(ID) … … 1130 1160 ID = wx.NewId() 1131 1161 self.panels[str(ID)] = p 1162 ## Check and set the size 1163 if PLOPANEL_WIDTH < 0: 1164 p_panel_width = int(self._window_width * 0.45) 1165 else: 1166 p_panel_width = PLOPANEL_WIDTH 1167 p_panel_height = int(p_panel_width * 0.76) 1168 p.frame.SetSize((p_panel_width, p_panel_height)) 1169 """ 1170 dw, dh = self._get_panels_size(self._data_panel) 1171 dw += p_panel_width 1172 _, dh = self.GetToolBar().GetSizeTuple() 1173 p.frame.SetPosition((dw, -dh)) 1174 """ 1132 1175 self.graph_num += 1 1133 1176 if p.window_caption.split()[0] in NOT_SO_GRAPH_LIST: … … 1154 1197 style2 = self.__gui_style & GUIFRAME.FLOATING_PANEL 1155 1198 1156 ## Check and set the size 1157 if PLOPANEL_WIDTH < 0: 1158 p_panel_width = int(self._window_width * 0.36) 1159 else: 1160 p_panel_width = PLOPANEL_WIDTH 1161 p_panel_height = int(p_panel_width * 0.75) 1162 1199 p.frame.SetTitle(p.window_caption) 1200 p.frame.name = p.window_name 1201 p.frame.Show(True) 1202 #if p not in self.schedule_full_draw_list: 1203 # self.schedule_full_draw_list.append(p) 1204 """ 1163 1205 if style1 == GUIFRAME.FIXED_PANEL: 1164 1206 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). … … 1176 1218 p_panel_height))) 1177 1219 self._popup_fixed_panel(p) 1178 1179 1220 elif style2 == GUIFRAME.FLOATING_PANEL: 1180 1221 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). … … 1188 1229 1189 1230 self._popup_floating_panel(p) 1231 """ 1190 1232 # Register for closing of panels 1191 self.Bind(wx.aui.EVT_AUI_PANE_CLOSE, self.on_panel_close)1233 #self.Bind(wx.aui.EVT_AUI_PANE_CLOSE, self.on_panel_close) 1192 1234 # Register for showing/hiding the panel 1193 1235 wx.EVT_MENU(self, ID, self.on_view) … … 1231 1273 self._add_menu_tool() 1232 1274 self._add_current_plugin_menu() 1233 self._add_menu_window()1275 #self._add_menu_window() 1234 1276 self._add_help_menu() 1235 1277 self.SetMenuBar(self._menubar) … … 1251 1293 application_name = 'No Selected Analysis' 1252 1294 panel_name = 'No Panel on Focus' 1253 c_panel = self.cpanel_on_focus 1295 c_panel = self.cpanel_on_focus 1254 1296 if self._toolbar is None: 1255 1297 return … … 1445 1487 self.panel = ConfDialog(parent=self, gui=self.__gui_style) 1446 1488 self.panel.ShowModal() 1447 #wx.PostEvent(self.parent, event)1448 1449 1450 def _add_menu_window(self):1451 """1452 add a menu window to the menu bar1453 Window menu1454 Attach a menu item for each panel in our1455 panel list that also appears in a plug-in.1456 1457 Only add the panel menu if there is only one perspective and1458 it has more than two panels.1459 Note: the first plug-in is always the plotting plug-in.1460 The first application1461 #plug-in is always the second one in the list.1462 """1463 self._window_menu = wx.Menu()1464 if self._plotting_plugin is not None:1465 for (menu, name) in self._plotting_plugin.populate_menu(self):1466 self._window_menu.AppendSubMenu(menu, name)1467 self._menubar.Append(self._window_menu, '&Graph')1468 1469 style = self.__gui_style & GUIFRAME.PLOTTING_ON1470 if style == GUIFRAME.PLOTTING_ON:1471 1472 self._window_menu.AppendSeparator()1473 id = wx.NewId()1474 hint = "Hide all the graph panels"1475 self._window_menu.Append(id, '&Hide All', hint)1476 wx.EVT_MENU(self, id, self.hide_all_plotpanels)1477 id = wx.NewId()1478 hint = "Show all the graph panels"1479 self._window_menu.Append(id, '&Show All', hint)1480 wx.EVT_MENU(self, id, self.show_all_plotpanels)1481 1482 self._window_menu.AppendSeparator()1483 id = wx.NewId()1484 preferences_menu = wx.Menu()1485 hint = "All plot panels will floating"1486 preferences_menu.AppendRadioItem(id, '&Float All', hint)1487 wx.EVT_MENU(self, id, self.set_plotpanel_floating)1488 style = self.__gui_style & GUIFRAME.FLOATING_PANEL1489 f_menu = preferences_menu.FindItemById(id)1490 if style == GUIFRAME.FLOATING_PANEL:1491 f_checked = True1492 else:1493 f_checked = False1494 f_menu.Check(f_checked)1495 1496 id = wx.NewId()1497 hint = "All plot panels will displayed within the frame"1498 preferences_menu.AppendRadioItem(id, '&Dock All', hint)1499 wx.EVT_MENU(self, id, self.set_plotpanel_fixed)1500 if not f_checked:1501 d_menu = preferences_menu.FindItemById(id)1502 d_menu.Check(True)1503 preferences_menu.AppendSeparator()1504 id = wx.NewId()1505 hint = "Clean up the dock area for plots on new-plot"1506 preferences_menu.AppendCheckItem(id, '&CleanUp Dock on NewPlot',1507 hint)1508 wx.EVT_MENU(self, id, self.on_cleanup_dock)1509 flag = self.cleanup_plots1510 if self.cleanup_plots:1511 c_menu = preferences_menu.FindItemById(id)1512 c_menu.Check(True)1513 self._window_menu.AppendSubMenu(preferences_menu,'&Preferences')1514 if self._window_menu.GetMenuItemCount() == 0:1515 pos = self._menubar.FindMenu('Graph')1516 self._menubar.Remove(pos)1517 #wx.EVT_MENU(self, id, self.show_preferences_panel)1518 #if len(self.plugins) == 2:1519 # plug = self.plugins[1]1520 # pers = plug.get_perspective()1521 #1522 # if len(pers) > 1:1523 # self._window_menu = wx.Menu()1524 # for item in self.panels:1525 # if item == 'default':1526 # continue1527 # panel = self.panels[item]1528 # if panel.window_name in pers:1529 # self._window_menu.Append(int(item),1530 # panel.window_caption,1531 # "Show %s window" % panel.window_caption)1532 # wx.EVT_MENU(self, int(item), self.on_view)1533 # self._menubar.Append(self._window_menu, '&Window')1534 1489 1535 1490 … … 1562 1517 "Switch to analysis: %s" % plug.sub_menu) 1563 1518 wx.EVT_MENU(self, id, plug.on_perspective) 1519 1564 1520 #self._applications_menu. 1565 1521 if (not plug_data_count or not plug_no_data_count): … … 1653 1609 'Preview current panel') 1654 1610 wx.EVT_MENU(self, GUIFRAME_ID.PREVIEW_ID, self.on_preview_panel) 1655 #self._edit_menu.Append(GUIFRAME_ID.PRINT_ID, '&Print', 1656 # 'Print current panel') 1657 #wx.EVT_MENU(self, GUIFRAME_ID.PRINT_ID, self.on_print_panel) 1611 1658 1612 self._edit_menu.Append(GUIFRAME_ID.RESET_ID, '&Reset Page', 1659 1613 'Reset current panel') … … 1716 1670 wx.CallLater(5*TIME_FACTOR, self.set_schedule(True)) 1717 1671 self.set_plot_unfocus() 1718 1719 def on_close_welcome_panel(self): 1720 """ 1721 Close the welcome panel 1722 """ 1723 if self.defaultPanel is None: 1724 return 1725 default_panel = self._mgr.GetPane(self.panels["default"].window_name) 1726 if default_panel.IsShown(): 1727 default_panel.Hide() 1728 # Recover current perspective 1729 perspective = self._current_perspective 1730 perspective.on_perspective(event=None) 1731 self._mgr.Update() 1732 # Show toolbar 1733 #style = self.__gui_style & GUIFRAME.TOOLBAR_ON 1734 #if (style == GUIFRAME.TOOLBAR_ON) & (not self._toolbar.IsShown()): 1735 # self._on_toggle_toolbar() 1736 1672 1737 1673 def show_welcome_panel(self, event): 1738 1674 """ … … 1741 1677 if self.defaultPanel is None: 1742 1678 return 1743 for id, panel in self.panels.iteritems(): 1744 if id == 'default': 1745 # Show default panel 1746 if not self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 1747 self._mgr.GetPane(self.panels["default"].window_name).Show(True) 1748 elif id == "data_panel": 1749 flag = self._mgr.GetPane(self.panels["data_panel"].window_name).IsShown() 1750 self._mgr.GetPane(self.panels["data_panel"].window_name).Show(flag) 1751 elif panel not in self.plot_panels.values() : 1752 self._mgr.GetPane(self.panels[id].window_name).IsShown() 1753 self._mgr.GetPane(self.panels[id].window_name).Hide() 1754 #style = self.__gui_style & GUIFRAME.TOOLBAR_ON 1755 #if (style == GUIFRAME.TOOLBAR_ON) & (self._toolbar.IsShown()): 1756 # # self._toolbar.Show(True) 1757 # self._on_toggle_toolbar() 1758 1759 self._mgr.Update() 1760 1761 def show_panel(self, uid, show=None): 1762 """ 1763 Shows the panel with the given id 1764 1765 :param uid: unique ID number of the panel to show 1766 1767 """ 1768 ID = str(uid) 1769 config.printEVT("show_panel: %s" % ID) 1770 if ID in self.panels.keys(): 1771 if not self._mgr.GetPane(self.panels[ID].window_name).IsShown(): 1772 if show == 'on': 1773 self._mgr.GetPane(self.panels[ID].window_name).Show() 1774 elif self.panels[ID].window_caption.split(" ")[0] == \ 1775 "Residuals": 1776 self._mgr.GetPane(self.panels[ID].window_name).Hide() 1777 else: 1778 self._mgr.GetPane(self.panels[ID].window_name).Show() 1779 # Hide default panel 1780 self._mgr.GetPane(self.panels["default"].window_name).Hide() 1781 self._mgr.Update() 1782 self._redraw_idle() 1783 1784 def show_all_plotpanels(self, event): 1785 """ 1786 Show all plotpanels shown 1787 1788 :param event: menu event 1789 """ 1790 #event.Skip() 1791 any_hidden = False 1792 for id in self.plot_panels.keys(): 1793 if self._mgr.GetPane(self.plot_panels[id].window_name).IsShown(): 1794 continue 1795 else: 1796 any_hidden = True 1797 self.show_panel(id) 1798 if not any_hidden: 1799 msg = "No hidden graph panel exists." 1800 else: 1801 # Make sure the Checkmenuitem checked: Need this for-loop \ 1802 # because the check menu is not responding on floating panel 1803 if IS_WIN: 1804 try: 1805 for item in self._plotting_plugin.menu.GetMenuItems(): 1806 item.Check(True) 1807 except: 1808 # MAC is not using checkmenuitem 1809 pass 1810 msg = "All graph panels are shown." 1811 wx.PostEvent(self, StatusEvent(status=msg)) 1812 1813 def hide_all_plotpanels(self, event): 1814 """ 1815 Hide all plotpanels shown 1816 1817 :param event: menu event 1818 """ 1819 #event.Skip() 1820 any_shown = False 1821 for ID in self.plot_panels.keys(): 1822 if self._mgr.GetPane(self.plot_panels[ID].window_name).IsShown(): 1823 any_shown = True 1824 try: 1825 self.hide_panel(ID) 1826 except: 1827 print "hide_panel: No such plot id %s" % ID 1828 else: 1829 continue 1830 if not any_shown: 1831 msg = "No shown graph panel exists." 1832 else: 1833 # Make sure the Checkmenuitem unchecked: Need this for-loop 1834 # because the check menu is not responding on floating panel 1835 if IS_WIN: 1836 try: 1837 for item in self._plotting_plugin.menu.GetMenuItems(): 1838 item.Check(False) 1839 except: 1840 # MAC is not using checkmenuitem 1841 pass 1842 msg = "All graph panels are hidden." 1843 wx.PostEvent(self, StatusEvent(status=msg)) 1844 1845 def hide_panel(self, uid): 1846 """ 1847 hide panel except default panel 1848 """ 1849 ID = str(uid) 1850 caption = self.panels[ID].window_caption 1851 config.printEVT("hide_panel: %s" % ID) 1852 if ID in self.panels.keys(): 1853 pane = self._mgr.GetPane(self.panels[ID].window_name) 1854 if pane.IsMaximized(): 1855 self._mgr.RestoreMaximizedPane() 1856 self.disable_app_menu(self.panels[ID]) 1857 if pane.IsShown(): 1858 pane.Hide() 1859 item = self._plotting_plugin.menu.FindItemById(uid) 1860 item.Check(False) 1861 if self._data_panel is not None and \ 1862 ID in self.plot_panels.keys(): 1863 self._data_panel.cb_plotpanel.Append(str(caption), 1864 self.panels[ID]) 1865 # Do not Hide default panel here... 1866 #self._mgr.GetPane(self.panels["default"].window_name).Hide() 1867 wx.CallAfter(self._mgr.Update) 1868 self.cpanel_on_focus.SetFocus() 1679 frame = self.panels['default'].get_frame() 1680 if frame == None: 1681 return 1682 # Show default panel 1683 if not frame.IsShown(): 1684 frame.Show(True) 1685 1686 def on_close_welcome_panel(self): 1687 """ 1688 Close the welcome panel 1689 """ 1690 if self.defaultPanel is None: 1691 return 1692 default_panel = self.panels["default"].frame 1693 if default_panel.IsShown(): 1694 default_panel.Show(False) 1869 1695 1870 1696 def delete_panel(self, uid): … … 1882 1708 self.panel_on_focus = None 1883 1709 panel = self.panels[ID] 1884 self._mgr.DetachPane(panel) 1710 #self._mgr.DetachPane(panel) 1711 if hasattr(panel, "connect"): 1712 panel.connect.disconnect() 1885 1713 self._plotting_plugin.delete_panel(panel.group_id) 1886 panel.Hide()1887 panel.clear()1888 panel.Close()1714 #panel.Hide() 1715 #panel.clear() 1716 #panel.Close() 1889 1717 if panel in self.schedule_full_draw_list: 1890 1718 self.schedule_full_draw_list.remove(panel) … … 1895 1723 if ID in self.panels.keys(): 1896 1724 del self.panels[ID] 1897 #CallAfter: make sure panel is clear before updating mgr1898 wx.CallAfter(self._mgr.Update)1899 1725 return 1900 1901 def clear_panel(self):1902 """1903 Clear the panel1904 """1905 for item in self.panels:1906 try:1907 self.panels[item].clear_panel()1908 except:1909 pass1910 1726 1911 1727 def create_gui_data(self, data, path=None): … … 1954 1770 if style == GUIFRAME.MANAGER_ON: 1955 1771 if self._data_panel is not None: 1956 #data_state = self._data_manager.get_selected_data() 1957 #self._data_panel.load_data_list(data_state) 1958 self._mgr.GetPane(self._data_panel.window_name).Show(True) 1772 self._data_panel.frame.Show(True) 1959 1773 1960 1774 def load_from_cmd(self, path): … … 1981 1795 1982 1796 self._default_save_location = os.path.dirname(path) 1983 1984 def load_state(self, path): 1797 1798 def show_panel(self, uid, show=None): 1799 """ 1800 Shows the panel with the given id 1801 1802 :param uid: unique ID number of the panel to show 1803 1804 """ 1805 ID = str(uid) 1806 config.printEVT("show_panel: %s" % ID) 1807 if ID in self.panels.keys(): 1808 if not self.panels[ID].frame.IsShown(): 1809 if show == 'on': 1810 self.panels[ID].frame.Show() 1811 elif self.panels[ID].window_caption.split(" ")[0] == \ 1812 "Residuals": 1813 self._mgr.GetPane(self.panels[ID].window_name).Hide() 1814 else: 1815 self._mgr.GetPane(self.panels[ID].window_name).Show() 1816 # Hide default panel 1817 self._mgr.GetPane(self.panels["default"].window_name).Hide() 1818 self._mgr.Update() 1819 self._redraw_idle() 1820 1821 def load_state(self, path, is_project=False): 1985 1822 """ 1986 1823 load data from command line or application … … 1990 1827 if APPLICATION_STATE_EXTENSION is not None \ 1991 1828 and basename.endswith(APPLICATION_STATE_EXTENSION): 1992 #Hide current plot_panels i 1993 for ID in self.plot_panels.keys(): 1994 panel = self._mgr.GetPane(self.plot_panels[ID].window_name) 1995 if panel.IsShown(): 1996 panel.Hide() 1829 if is_project: 1830 for ID in self.plot_panels.keys(): 1831 panel = self.plot_panels[ID] 1832 panel.on_close(None) 1997 1833 self.get_data(path) 1998 1834 wx.PostEvent(self, StatusEvent(status="Completed loading.")) 1999 1835 else: 2000 1836 wx.PostEvent(self, StatusEvent(status=" ")) 2001 if self.defaultPanel is not None and \2002 self._mgr.GetPane(self.panels["default"].window_name).IsShown():2003 self.on_close_welcome_panel()1837 #if self.defaultPanel is not None and \ 1838 # self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 1839 # self.on_close_welcome_panel() 2004 1840 2005 1841 def load_data(self, path): … … 2132 1968 #except: 2133 1969 2134 self.load_state(path=path )1970 self.load_state(path=path, is_project=True) 2135 1971 2136 1972 def _on_save_application(self, event): … … 2416 2252 :param panels: list of panels 2417 2253 """ 2418 #style = self.__gui_style & GUIFRAME.TOOLBAR_ON 2419 #if (style == GUIFRAME.TOOLBAR_ON) & (not self._toolbar.IsShown()): 2420 # self._on_toggle_toolbar() 2421 for item in self.panels: 2254 for item in self.panels.keys(): 2422 2255 # Check whether this is a sticky panel 2423 2256 if hasattr(self.panels[item], "ALWAYS_ON"): 2424 2257 if self.panels[item].ALWAYS_ON: 2425 2258 continue 2426 2259 if self.panels[item] == None: 2260 continue 2427 2261 if self.panels[item].window_name in panels: 2428 if not self._mgr.GetPane(self.panels[item].window_name).IsShown(): 2429 self._mgr.GetPane(self.panels[item].window_name).Show() 2262 frame = self.panels[item].get_frame() 2263 if not frame.IsShown(): 2264 frame.Show(True) 2430 2265 else: 2431 2266 # always show the data panel if enable … … 2433 2268 if (style == GUIFRAME.MANAGER_ON) and self.panels[item] == self._data_panel: 2434 2269 if 'data_panel' in self.panels.keys(): 2435 flag = self._mgr.GetPane(self.panels['data_panel'].window_name).IsShown() 2436 self._mgr.GetPane(self.panels['data_panel'].window_name).Show(flag) 2270 frame = self.panels['data_panel'].get_frame() 2271 if frame == None: 2272 continue 2273 flag = frame.IsShown() 2274 frame.Show(flag) 2437 2275 else: 2438 if self._mgr.GetPane(self.panels[item].window_name).IsShown(): 2439 self._mgr.GetPane(self.panels[item].window_name).Hide() 2440 2441 self._mgr.Update() 2276 frame = self.panels[item].get_frame() 2277 if frame == None: 2278 continue 2279 2280 if frame.IsShown(): 2281 frame.Show(False) 2442 2282 2443 2283 def show_data_panel(self, event=None, action=True): … … 2448 2288 return 2449 2289 label = self._data_panel_menu.GetText() 2290 pane = self.panels["data_panel"] 2291 frame = pane.get_frame() 2450 2292 if label == 'Show Data Explorer': 2451 pane = self._mgr.GetPane(self.panels["data_panel"].window_name)2452 2293 #if not pane.IsShown(): 2453 2294 if action: 2454 pane.Show(True) 2455 self._mgr.Update() 2295 frame.Show(True) 2456 2296 self.__gui_style = self.__gui_style | GUIFRAME.MANAGER_ON 2457 2458 2297 self._data_panel_menu.SetText('Hide Data Explorer') 2459 2298 else: 2460 pane = self._mgr.GetPane(self.panels["data_panel"].window_name)2461 #if not pane.IsShown():2462 2299 if action: 2463 pane.Show(False) 2464 self._mgr.Update() 2300 frame.Show(False) 2465 2301 self.__gui_style = self.__gui_style & (~GUIFRAME.MANAGER_ON) 2466 2302 self._data_panel_menu.SetText('Show Data Explorer') 2467 2303 2468 2304 def add_data_helper(self, data_list): 2469 2305 """ … … 2493 2329 #wait for button press from the data panel to set_data 2494 2330 if self._data_panel is not None: 2495 self._mgr.GetPane(self._data_panel.window_name).Show(True) 2496 self._mgr.Update() 2331 self._data_panel.frame.Show(True) 2497 2332 else: 2498 2333 #automatically send that to the current perspective 2499 2334 self.set_data(data_id=data_list.keys()) 2500 self.on_close_welcome_panel()2501 2335 2502 2336 def set_data(self, data_id, theory_id=None): … … 2506 2340 list_data, _ = self._data_manager.get_by_id(data_id) 2507 2341 if self._current_perspective is not None: 2508 if self.cleanup_plots:2509 for uid, panel in self.plot_panels.iteritems():2510 #panel = self.plot_panels[uid]2511 window = self._mgr.GetPane(panel.window_name)2512 # To hide all docked plot panels when set the data2513 if not window.IsFloating():2514 self.hide_panel(uid)2515 2342 self._current_perspective.set_data(list_data.values()) 2516 self.on_close_welcome_panel() 2343 2517 2344 else: 2518 2345 msg = "Guiframe does not have a current perspective" … … 2566 2393 info='warning')) 2567 2394 else: 2568 if self.cleanup_plots:2569 for id, panel in self.plot_panels.iteritems():2570 window = self._mgr.GetPane(panel.window_name)2571 # To hide all docked plot panels when set the data2572 if not window.IsFloating():2573 self.hide_panel(id)2574 2395 #if not append then new plot 2575 2396 from sans.guiframe.dataFitting import Data2D … … 2593 2414 """ 2594 2415 temp = data_id + theory_id 2595 """2596 value = [plug.is_in_use(temp) for plug in self.plugins]2597 if len(value) > 0:2598 print "value"2599 return2600 from data_panel import DataDialog2601 dlg = DataDialog(data_list=data_list, nb_data=MAX_NBR_DATA)2602 if dlg.ShowModal() == wx.ID_OK:2603 selected_data_list = dlg.get_data()2604 dlg.Destroy()2605 """2606 2416 for plug in self.plugins: 2607 2417 plug.delete_data(temp) … … 2892 2702 if hasattr(panel, 'CENTER_PANE') and panel.CENTER_PANE: 2893 2703 for name in self._current_perspective.get_perspective(): 2894 if name == panel.window_name: 2895 panel.on_set_focus(event=None) 2896 break 2704 frame = panel.get_frame() 2705 if frame != None: 2706 if name == panel.window_name: 2707 panel.on_set_focus(event=None) 2708 frame.Show(True) 2709 else: 2710 frame.Show(False) 2711 #break 2897 2712 name = self._current_perspective.sub_menu 2898 2713 if self._data_panel is not None: … … 2901 2716 #Set the SasView title 2902 2717 self._set_title_name(name) 2903 2904 2718 2905 2719 def _set_title_name(self, name): … … 2926 2740 else: 2927 2741 menu.Check(False) 2928 2929 def set_plotpanel_floating(self, event=None):2930 """2931 make the plot panel floatable2932 """2933 2934 self.__gui_style &= (~GUIFRAME.FIXED_PANEL)2935 self.__gui_style |= GUIFRAME.FLOATING_PANEL2936 plot_panel = []2937 id = event.GetId()2938 menu = self._window_menu.FindItemById(id)2939 if self._plotting_plugin is not None:2940 plot_panel = self.plot_panels.values()2941 for p in plot_panel:2942 self._popup_floating_panel(p)2943 menu.Check(True)2944 2945 def set_plotpanel_fixed(self, event=None):2946 """2947 make the plot panel fixed2948 """2949 self.__gui_style &= (~GUIFRAME.FLOATING_PANEL)2950 self.__gui_style |= GUIFRAME.FIXED_PANEL2951 plot_panel = []2952 id = event.GetId()2953 menu = self._window_menu.FindItemById(id)2954 if self._plotting_plugin is not None:2955 plot_panel = self.plot_panels.values()2956 for p in plot_panel:2957 self._popup_fixed_panel(p)2958 menu.Check(True)2959 2960 def on_cleanup_dock(self, event=None):2961 """2962 Set Cleanup Dock option2963 """2964 if event == None:2965 return2966 id = event.GetId()2967 menu = self._window_menu.FindItemById(id)2968 Flag = self.cleanup_plots2969 if not Flag:2970 menu.Check(True)2971 self.cleanup_plots = True2972 msg = "Cleanup-Dock option set to 'ON'."2973 else:2974 menu.Check(False)2975 self.cleanup_plots = False2976 msg = "Cleanup-Dock option set to 'OFF'."2977 2978 wx.PostEvent(self, StatusEvent(status= msg))2979 2980 def _popup_fixed_panel(self, p):2981 """2982 """2983 style = self.__gui_style & GUIFRAME.FIXED_PANEL2984 if style == GUIFRAME.FIXED_PANEL:2985 pane = self._mgr.GetPane(p.window_name)2986 pane.Dock()2987 pane.Floatable()2988 pane.Right()2989 pane.TopDockable(False)2990 pane.BottomDockable(False)2991 pane.LeftDockable(False)2992 pane.RightDockable(True)2993 self._mgr.Update()2994 2995 def _popup_floating_panel(self, p):2996 """2997 """2998 style = self.__gui_style & GUIFRAME.FLOATING_PANEL2999 if style == GUIFRAME.FLOATING_PANEL:3000 pane = self._mgr.GetPane(p.window_name)3001 pane.Floatable(True)3002 pane.Float()3003 pane.Dockable(False)3004 self._mgr.Update()3005 2742 3006 2743 def enable_add_data(self, new_plot): … … 3233 2970 : return: AuiPaneInfo of the name 3234 2971 """ 3235 return self._mgr.GetPane(name)2972 return None#self._mgr.GetPane(name) 3236 2973 3237 2974 def enable_undo(self): … … 3325 3062 if self.cpanel_on_focus is not None: 3326 3063 self._toolbar.enable_reset(self.panel_on_focus) 3327 3064 3065 def get_toolbar_height(self): 3066 """ 3067 """ 3068 size_y = 0 3069 if self.GetToolBar() != None and self.GetToolBar().IsShown(): 3070 _, size_y = self.GetToolBar().GetSizeTuple() 3071 return size_y 3072 3328 3073 def set_schedule_full_draw(self, panel=None, func='del'): 3329 3074 """ … … 3354 3099 Draw the panels with axes in the schedule to full dwar list 3355 3100 """ 3101 3356 3102 count = len(self.schedule_full_draw_list) 3357 3103 #if not self.schedule: … … 3359 3105 self.set_schedule(False) 3360 3106 return 3107 3361 3108 else: 3362 3109 ind = 0 … … 3364 3111 for panel in self.schedule_full_draw_list: 3365 3112 ind += 1 3366 if self._mgr.GetPane(panel.window_name).IsShown():3113 if panel.frame.IsShown(): 3367 3114 break 3368 3115 # otherwise, return 3369 3116 if ind == count: 3370 3117 return 3371 3372 3118 #Simple redraw only for a panel shown 3373 3119 def f_draw(panel): … … 3378 3124 # This checking of GetCapture is to stop redrawing 3379 3125 # while any panel is capture. 3380 if self.GetCapture() == None: 3126 frame = panel.frame 3127 3128 if not frame.GetCapture(): 3381 3129 # draw if possible 3382 3130 panel.set_resizing(False) 3383 panel.Show(False)3131 #panel.Show(True) 3384 3132 panel.draw_plot() 3385 3386 # Check if the panel is not shown 3387 if not self._mgr.GetPane(panel.window_name).IsShown(): 3388 self._mgr.GetPane(panel.window_name).Hide() 3389 else: 3390 panel.Show(True) 3133 # Check if the panel is not shown 3134 flag = frame.IsShown() 3135 frame.Show(flag) 3136 3391 3137 except: 3392 pass3393 3138 raise 3139 3394 3140 # Draw all panels 3395 map(f_draw, self.schedule_full_draw_list)3396 3141 #map(f_draw, self.schedule_full_draw_list) 3142 f_draw(self.schedule_full_draw_list[0]) 3397 3143 # Reset the attr 3398 3144 if len(self.schedule_full_draw_list) == 0: … … 3400 3146 else: 3401 3147 self.set_schedule(True) 3402 # do not update mgr3403 #self._mgr.Update()3404 3148 3405 3149 def set_schedule(self, schedule=False): … … 3703 3447 style=(wx.SIMPLE_BORDER| 3704 3448 wx.FRAME_NO_TASKBAR| 3705 wx. STAY_ON_TOP),3449 wx.FRAME_FLOAT_ON_PARENT), 3706 3450 3707 3451 milliseconds=SS_MAX_DISPLAY_TIME, … … 3724 3468 self.maximize_win() 3725 3469 3470 3471 class MDIFrame(wx.MDIChildFrame): 3472 """ 3473 Frame for panels 3474 """ 3475 def __init__(self, parent, panel, title="Untitled", 3476 size=(300,200), *args, **kwds): 3477 """ 3478 comment 3479 :param parent: parent panel/container 3480 """ 3481 kwds['size']= size 3482 kwds['title']= title 3483 # Initialize the Frame object 3484 wx.MDIChildFrame.__init__(self, parent, *args, **kwds) 3485 self.parent = parent 3486 self.name = "Untitled" 3487 self.batch_on = self.parent.batch_on 3488 self.panel = panel 3489 if panel != None: 3490 self.set_panel(panel) 3491 self.Show(False) 3492 3493 def show_data_panel(self, action): 3494 """ 3495 """ 3496 self.parent.show_data_panel(action) 3497 3498 def set_panel(self, panel): 3499 """ 3500 """ 3501 self.panel = panel 3502 self.name = panel.window_name 3503 self.SetTitle(panel.window_caption) 3504 self.SetHelpText(panel.help_string) 3505 width, height = self.parent._get_panels_size(panel) 3506 if hasattr(panel, "CENTER_PANE") and panel.CENTER_PANE: 3507 width *= 0.6 3508 self.SetSize((width, height)) 3509 self.parent.put_icon(self) 3510 self.Bind(wx.EVT_SET_FOCUS, self.set_panel_focus) 3511 self.Bind(wx.EVT_CLOSE, self.OnClose) 3512 self.Show(False) 3513 3514 def set_panel_focus(self, event): 3515 """ 3516 """ 3517 self.panel.SetFocus() 3518 self.parent.panel_on_focus = self.panel 3519 #self.parent.set_panel_on_focus_helper() 3520 3521 def OnClose(self, event): 3522 """ 3523 On Close event 3524 """ 3525 #event.Skip() 3526 self.panel.on_close(event) 3527 #self.parent.delete_panel(event) 3528 #self.DestroyChildren() 3529 #self.panel = None 3530 #wx.CallAfter(self.Destroy) 3531 3726 3532 if __name__ == "__main__": 3727 3533 app = ViewApp(0) -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py
r3e001f9 rae84427 73 73 ## Reference to the parent window 74 74 self.parent = parent 75 if hasattr(parent, "parent"): 76 self.parent = self.parent.parent 75 77 ## Plottables 76 78 self.plots = {} 79 self.frame = None 77 80 #context menu 78 81 self._slicerpop = None … … 335 338 """ 336 339 ax = event.inaxes 337 dclick = event.action == 'dclick' 338 if ax == None or dclick: 339 # remove the vline 340 self._check_zoom_plot() 341 self.canvas.draw() 342 self.q_ctrl = None 343 return 340 if hasattr(event, "action"): 341 dclick = event.action == 'dclick' 342 if ax == None or dclick: 343 # remove the vline 344 self._check_zoom_plot() 345 self.canvas.draw() 346 self.q_ctrl = None 347 return 344 348 if self.ly != None and event.xdata != None: 345 349 # Selecting a new line if cursor lines are displayed already … … 442 446 data = theory_list[id] 443 447 # Update Graph menu and help string 444 h_id = self.parent._window_menu.FindItem(self.window_caption)448 #h_id = self.parent._window_menu.FindItem(self.window_caption) 445 449 if data != None: 446 450 if data.__class__.__name__ == 'list': … … 450 454 else: 451 455 label = '???' 452 helpString = self.parent._window_menu.GetHelpString(h_id)456 #helpString = self.parent._window_menu.GetHelpString(h_id) 453 457 d_string = (' ' + str(label) +';') 454 new_tip = helpString.replace(d_string, '')455 self.parent._window_menu.SetHelpString(h_id, new_tip)458 #new_tip = helpString.replace(d_string, '') 459 #self.parent._window_menu.SetHelpString(h_id, new_tip) 456 460 457 461 del self.plots[id] … … 518 522 self.is_zoomed = False 519 523 # Update Graph menu and help string 520 pos = self.parent._window_menu.FindItem(self.window_caption)524 #pos = self.parent._window_menu.FindItem(self.window_caption) 521 525 helpString = 'Show/Hide Graph: ' 522 526 for plot in self.plots.itervalues(): 523 527 helpString += (' ' + str(plot.label) +';') 524 self.parent._window_menu.SetHelpString(pos, helpString)525 528 #self.parent._window_menu.SetHelpString(pos, helpString) 529 526 530 def draw_plot(self): 527 531 """ … … 801 805 Add refresh, add/hide button in the tool bar 802 806 """ 807 return 803 808 if self.parent.__class__.__name__ != 'ViewerFrame': 804 809 return … … 817 822 self.parent.hide_panel(self.uid) 818 823 824 def on_close(self, event): 825 """ 826 On Close Event 827 """ 828 ID = self.uid 829 self.parent.delete_panel(ID) 830 819 831 def createAppDialog(self, event): 820 832 """ … … 859 871 self.appearance_selected_plot.label = str(info[3]) 860 872 861 pos = self.parent._window_menu.FindItem(self.window_caption)862 helpString = 'Show/Hide Graph: '863 for plot in self.plots.itervalues():864 helpString += (' ' + str(plot.label) + ';')865 self.parent._window_menu.SetHelpString(pos, helpString)866 self._is_changed_legend_label = True873 #pos = self.parent._window_menu.FindItem(self.window_caption) 874 #helpString = 'Show/Hide Graph: ' 875 #for plot in self.plots.itervalues(): 876 # helpString += (' ' + str(plot.label) + ';') 877 # self.parent._window_menu.SetHelpString(pos, helpString) 878 # self._is_changed_legend_label = True 867 879 868 880 self.appD.Destroy() -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter2D.py
r3e001f9 rae84427 106 106 """ 107 107 ModelPanel1D.__init__(self, parent, id=id, style=style, **kwargs) 108 108 self.parent = parent 109 109 ## Reference to the parent window 110 self.parent = parent 110 if hasattr(parent, "parent"): 111 self.parent = self.parent.parent 111 112 ## Dictionary containing Plottables 112 113 self.plots = {} … … 247 248 self.subplot.figure.canvas.draw_idle() 248 249 # Update Graph menu and help string 249 pos = self.parent._window_menu.FindItem(self.window_caption)250 #pos = self.parent._window_menu.FindItem(self.window_caption) 250 251 helpString = 'Show/Hide Graph: ' 251 252 helpString += (' ' + str(data.label) +';') 252 self.parent._window_menu.SetHelpString(pos, helpString)253 #self.parent._window_menu.SetHelpString(pos, helpString) 253 254 ## store default value of zmin and zmax 254 255 self.default_zmin_ctl = self.zmin_2D … … 467 468 # Update Graph menu and help string 468 469 if self.title_label != None: 469 pos = self.parent._window_menu.FindItem(self.window_caption)470 #pos = self.parent._window_menu.FindItem(self.window_caption) 470 471 helpString = 'Show/Hide Graph: ' 471 472 helpString += (' ' + str(self.title_label) +';') 472 self.parent._window_menu.SetHelpString(pos, helpString)473 #self.parent._window_menu.SetHelpString(pos, helpString) 473 474 474 475 … … 691 692 """ 692 693 """ 694 from sans.guiframe.gui_manager import MDIFrame 693 695 from boxSum import BoxSum 694 696 self.onClearSlicer(event) … … 704 706 ## Create a new panel to display results of summation of Data2D 705 707 from slicerpanel import SlicerPanel 706 new_panel = SlicerPanel(parent=self.parent, id=-1, 708 win = MDIFrame(self.parent, None, 'None', (100, 200)) 709 new_panel = SlicerPanel(parent=win, id=-1, 707 710 base=self, type=type, 708 711 params=params, style=wx.RAISED_BORDER) … … 713 716 str(self.data2D.name) 714 717 ## Store a reference of the new created panel 715 self.panel_slicer = new_panel718 716 719 ## save the window_caption of the new panel in the current slicer 717 720 self.slicer.set_panel_name(name=new_panel.window_caption) 718 721 ## post slicer panel to guiframe to display it 719 722 from sans.guiframe.events import SlicerPanelEvent 720 wx.PostEvent(self.parent, SlicerPanelEvent(panel=self.panel_slicer, 723 724 win.set_panel(new_panel) 725 new_panel.frame = win 726 wx.PostEvent(self.parent, SlicerPanelEvent(panel=new_panel, 721 727 main_panel=self)) 722 728 wx.CallAfter(new_panel.frame.Show) 729 self.panel_slicer = new_panel 730 723 731 def onBoxavgX(self,event): 724 732 """ -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/SimplePlot.py
r9e9e9a5 rae84427 21 21 """ 22 22 PlotPanel.__init__(self, parent, id=id, style=style, **kwargs) 23 23 24 self.SetColor(wx.WHITE) 24 25 … … 198 199 """ 199 200 # Initialize the Frame object 200 wx.Frame.__init__(self, parent, id, title, 201 wx.DefaultPosition, size) 201 wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, size) 202 202 203 203 # Panel for 1D plot -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/plotting.py
r3e001f9 rae84427 21 21 from sans.guiframe.dataFitting import Data1D 22 22 from sans.guiframe.dataFitting import Data2D 23 23 from sans.guiframe.gui_manager import MDIFrame 24 24 DEFAULT_MENU_ITEM_LABEL = "No graph available" 25 25 DEFAULT_MENU_ITEM_ID = wx.NewId() … … 69 69 70 70 """ 71 return [] 72 """ 71 73 self.menu = wx.Menu() 72 74 self.menu.Append(DEFAULT_MENU_ITEM_ID, DEFAULT_MENU_ITEM_LABEL, … … 74 76 self.menu.FindItemByPosition(0).Enable(False) 75 77 return [(self.menu, "Show")] 78 """ 76 79 77 80 def get_panels(self, parent): … … 126 129 self.hide_panel(group_id) 127 130 self.plot_panels = {} 128 item = self.menu.FindItemByPosition(0)129 while item != None:130 self.menu.DeleteItem(item)131 try:132 item = self.menu.FindItemByPosition(0)133 except:134 item = None135 136 131 137 132 def clear_panel_by_id(self, group_id): … … 151 146 hide panel with group ID = group_id 152 147 """ 153 if group_id in self.plot_panels.keys(): 154 panel = self.plot_panels[group_id] 155 self.parent.hide_panel(panel.uid) 156 return True 148 # Not implemeted 157 149 return False 158 150 … … 171 163 new_panel.window_name = data.title 172 164 event_id = self.parent.popup_panel(new_panel) 173 #remove the default item in the menu 174 if len(self.plot_panels) == 0: 175 pos = self.menu.FindItem(DEFAULT_MENU_ITEM_LABEL) 176 if pos != -1: 177 self.menu.Delete(DEFAULT_MENU_ITEM_ID) 165 178 166 # Set UID to allow us to reference the panel later 179 167 new_panel.uid = event_id 180 168 # Ship the plottable to its panel 181 169 wx.CallAfter(new_panel.plot_data, data) 170 #new_panel.canvas.set_resizing(new_panel.resizing) 182 171 self.plot_panels[new_panel.group_id] = new_panel 183 172 184 173 # Set Graph menu and help string 185 helpString = 'Show/HideGraph: '174 self.help_string = ' Graph: ' 186 175 for plot in new_panel.plots.itervalues(): 187 help String += (' ' + plot.label + ';')188 self.menu.AppendCheckItem(event_id, new_panel.window_caption,189 helpString)190 self.menu.Check(event_id, IS_WIN)191 wx.EVT_MENU(self.parent, event_id, self._on_check_menu)176 help_string += (' ' + plot.label + ';') 177 #self.menu.AppendCheckItem(event_id, new_panel.window_caption, 178 # helpString) 179 #self.menu.Check(event_id, IS_WIN) 180 #wx.EVT_MENU(self.parent, event_id, self._on_check_menu) 192 181 193 182 … … 203 192 ytransform = data.ytransform 204 193 ## create a plotpanel for 1D Data 205 new_panel = ModelPanel1D(self.parent, -1, xtransform=xtransform, 194 win = MDIFrame(self.parent, None, 'None', (100, 200)) 195 new_panel = ModelPanel1D(win, -1, xtransform=xtransform, 206 196 ytransform=ytransform, style=wx.RAISED_BORDER) 197 win.set_panel(new_panel) 198 win.Show(False) 199 new_panel.frame = win 200 #win.Show(True) 207 201 return new_panel 208 202 … … 217 211 from Plotter2D import ModelPanel2D 218 212 scale = data.scale 219 new_panel = ModelPanel2D(self.parent, id = -1, 213 win = MDIFrame(self.parent, None, 'None', (200, 150)) 214 win.Show(False) 215 new_panel = ModelPanel2D(win, id = -1, 220 216 data2d=data, scale = scale, 221 217 style=wx.RAISED_BORDER) 218 win.set_panel(new_panel) 219 new_panel.frame = win 220 #win.Show(True) 222 221 return new_panel 223 222 msg = "2D Panel of group ID %s could not be created" % str(group_id) … … 247 246 data.list_group_id.append(panel.group_id) 248 247 wx.CallAfter(panel.plot_data, data) 249 #Do not show residual plot when it is hidden 250 #ToDo: find better way 251 if str(panel.group_id)[0:3] == 'res' and not panel.IsShown(): 252 return 253 self.parent.show_panel(panel.uid) 254 255 def delete_menu_item(self, name, uid): 256 """ 257 """ 258 #remove menu item 259 pos = self.menu.FindItem(name) 260 if pos != -1: 261 self.menu.Delete(uid) 262 if self.menu.GetMenuItemCount() == 0: 263 self.menu.Append(DEFAULT_MENU_ITEM_ID, DEFAULT_MENU_ITEM_LABEL, 264 "No graph available") 265 self.menu.FindItemByPosition(0).Enable(False) 266 248 267 249 def delete_panel(self, group_id): 268 250 """ … … 275 257 caption=panel.window_caption)) 276 258 #remove menu item 277 self.delete_menu_item(panel.window_caption, panel.uid)259 #self.delete_menu_item(panel.window_caption, panel.uid) 278 260 del self.plot_panels[group_id] 279 261 if uid in self.parent.plot_panels.keys(): 280 262 del self.parent.plot_panels[uid] 263 panel.frame.Destroy() 281 264 return True 282 265 … … 352 335 self.create_panel_helper(new_panel, data, group_id, title) 353 336 return 354 355 def _on_check_menu(self, event): 356 """ 357 Check mark on menu 358 """ 359 #event.Skip() 360 event_id = event.GetId() 361 362 if self.menu.IsChecked(event_id): 363 self.parent.on_view(event) 364 self.menu.Check(event_id, IS_WIN) 365 else: 366 self.parent.hide_panel(event_id) 367 self.menu.Check(event_id, False) 368 337 369 338 def help(self, evt): 370 339 """ -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/profile_dialog.py
r657e52c rae84427 195 195 Show data dialog 196 196 """ 197 self.parent. parent.parent.show_data1d(data, name)197 self.parent._manager.parent.show_data1d(data, name) 198 198 199 199 class SLDplotpanel(PlotPanel): … … 300 300 # What an ancestor! 301 301 fit_panel = self.parent.parent.parent 302 fit_panel. parent.save_data1d(data, default_name)302 fit_panel._manager.parent.save_data1d(data, default_name) 303 303 304 304 class ViewerFrame(wx.Frame): -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/slicerpanel.py
rd555416 rae84427 32 32 params = {} 33 33 self.params = params 34 self.parent = parent 34 self.parent = base.parent 35 self.frame = None 35 36 self.type = type 36 37 self.listeners = [] … … 118 119 #self.bck.Fit(self) 119 120 self.Layout() 120 self.parent.GetSizer().Layout() 121 psizer = self.parent.GetSizer() 122 if psizer != None: 123 psizer.Layout() 121 124 122 125 def onSetFocus(self, evt): … … 163 166 event = SlicerParameterEvent(type=self.type, params=params) 164 167 wx.PostEvent(self.base, event) 165 166 168 169 def on_close(self, event): 170 """ 171 On Close Event 172 """ 173 ID = self.uid 174 self.parent.delete_panel(ID) 175 self.frame.Destroy() -
sansguiframe/src/sans/guiframe/panel_base.py
r225ed2d rae84427 57 57 58 58 self.group_id = None 59 self.help_string = '' 59 60 60 61 def on_batch_selection(self, event): … … 426 427 """ 427 428 """ 428 return self._manager 429 return self._manager 430 431 def get_frame(self): 432 """ 433 """ 434 if self._manager == None: 435 return None 436 return self._manager.frame 437 438 def on_close(self, event): 439 """ 440 On Close Event 441 """ 442 if self.frame != None: 443 self.frame.Destroy() 444 -
sansguiframe/src/sans/guiframe/plugin_base.py
rda7cacb rae84427 41 41 ## Reference to the parent window. Filled by get_panels() below. 42 42 self.parent = None 43 self.frame = None 43 44 #plugin state reader 44 45 self.state_reader = None … … 145 146 return [] 146 147 148 def get_frame(self): 149 """ 150 Returns MDIChildFrame 151 """ 152 return self.frame 153 154 def _frame_set_helper(self): 155 """ 156 Sets default frame config 157 """ 158 if self.frame != None: 159 self.frame.EnableCloseButton(False) 160 self.frame.Show(False) 161 147 162 def get_panels(self, parent): 148 163 """ … … 212 227 213 228 """ 229 old_frame = None 230 tool_height = self.parent.get_toolbar_height() 231 old_persp = self.parent.get_current_perspective() 232 if old_persp != None: 233 old_frame = old_persp.get_frame() 214 234 self.parent.check_multimode(self) 215 235 self.parent.set_current_perspective(self) 216 236 self.parent.set_perspective(self.perspective) 237 238 if self.frame != None: 239 if old_frame != None: 240 pos_x, pos_y = old_frame.GetPositionTuple() 241 self.frame.SetPosition((pos_x, pos_y - tool_height)) 242 if not self.frame.IsShown(): 243 self.frame.Show(True) 217 244 218 245 -
sansguiframe/src/sans/guiframe/startup_configuration.py
r657e52c rae84427 126 126 p_size = None 127 127 for panel in self.parent.plot_panels.values(): 128 p_panel = self.parent._mgr.GetPane(panel.window_name) 129 if p_panel.IsShown(): 130 if p_size == None or panel.size > p_size: 131 p_size = panel.size 128 #p_panel = self.parent._mgr.GetPane(panel.window_name) 129 width, _ = panel.frame.GetSizeTuple() 130 if panel.frame.IsShown(): 131 if p_size == None or width > p_size: 132 p_size = width 132 133 if p_size == None: 133 134 p_size = CURRENT_STRINGS['PLOPANEL_WIDTH'] 134 135 self.current_string['PLOPANEL_WIDTH'] = p_size 135 136 136 data_pw, _ = self.parent.panels["data_panel"]. GetSizeTuple()137 data_pw, _ = self.parent.panels["data_panel"].frame.GetSizeTuple() 137 138 if data_pw == None: 138 139 data_pw = CURRENT_STRINGS['DATAPANEL_WIDTH'] … … 140 141 141 142 #label = self.parent._data_panel_menu.GetText() 142 label = self.parent._mgr.GetPane(\ 143 self.parent.panels['data_panel'].window_name).IsShown() 143 label = self.parent.panels['data_panel'].frame.IsShown() 144 144 if label:# == 'Hide Data Explorer': 145 145 self.current_string['DATALOADER_SHOW'] = True … … 158 158 self.current_string['FIXED_PANEL'] = True 159 159 160 if self.parent. _mgr.GetPane(self.parent.panels['default'].window_name).IsShown():160 if self.parent.panels['default'].frame.IsShown(): 161 161 self.current_string['WELCOME_PANEL_SHOW'] = True 162 162 else: … … 197 197 fname = os.path.join(self.path, 'custom_config.py') 198 198 self.write_string(fname, self.return_string) 199 200 199 self.Destroy() 201 200
Note: See TracChangeset
for help on using the changeset viewer.