Changeset 9687d58 in sasview for src/sas/sasgui/guiframe/data_panel.py
- Timestamp:
- Apr 10, 2017 4:01:46 AM (8 years ago)
- Branches:
- 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
- Children:
- 6c8fb2c
- Parents:
- 9208346 (diff), c6f3aec (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/data_panel.py
rd6e36e44 r9687d58 1 1 ################################################################################ 2 # This software was developed by the University of Tennessee as part of the3 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE)4 # project funded by the US National Science Foundation.2 # This software was developed by the University of Tennessee as part of the 3 # Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 # project funded by the US National Science Foundation. 5 5 # 6 # See the license text in license.txt6 # See the license text in license.txt 7 7 # 8 # copyright 2010, University of Tennessee8 # copyright 2010, University of Tennessee 9 9 ################################################################################ 10 10 """ … … 14 14 from wx.build import build_options 15 15 16 # Check version17 toks = str(wx.__version__).split('.')18 if int(toks[1]) < 9:19 if int(toks[2]) < 12:20 wx_version = 81121 else:22 wx_version = 81223 else:24 wx_version = 90025 16 import sys 26 17 from wx.lib.scrolledpanel import ScrolledPanel 27 import 18 import wx.lib.agw.customtreectrl as CT 28 19 from sas.sasgui.guiframe.dataFitting import Data1D 29 20 from sas.sasgui.guiframe.dataFitting import Data2D … … 36 27 from sas.sasgui.guiframe.events import NewBatchEvent 37 28 from sas.sascalc.dataloader.loader import Loader 38 # from sas.sasgui.guiframe.local_perspectives.plotting.masking \29 # from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 39 30 # import FloatPanel as QucikPlotDialog 40 from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame\41 31 from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \ 32 import PlotFrame as QucikPlotDialog 42 33 import sas.sasgui.guiframe.config as config 34 35 # Check version 36 toks = str(wx.__version__).split('.') 37 if int(toks[1]) < 9: 38 if int(toks[2]) < 12: 39 wx_version = 811 40 else: 41 wx_version = 812 42 else: 43 wx_version = 900 43 44 44 45 extension_list = [] … … 49 50 APPLICATION_WLIST = config.APPLICATION_WLIST 50 51 51 # Control panel width52 # Control panel width 52 53 if sys.platform.count("win32") > 0: 53 54 PANEL_WIDTH = 235 … … 65 66 IS_MAC = True 66 67 67 STYLE_FLAG = wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\68 wx.WANTS_CHARS |CT.TR_HAS_VARIABLE_ROW_HEIGHT68 STYLE_FLAG = (wx.RAISED_BORDER | CT.TR_HAS_BUTTONS | 69 wx.WANTS_CHARS | CT.TR_HAS_VARIABLE_ROW_HEIGHT) 69 70 70 71 … … 73 74 Check list control to be used for Data Panel 74 75 """ 75 def __init__(self, parent, *args, **kwds):76 # agwstyle is introduced in wx.2.8.11 but is not working for mac76 def __init__(self, parent, root, *args, **kwds): 77 # agwstyle is introduced in wx.2.8.11 but is not working for mac 77 78 if IS_MAC and wx_version < 812: 78 79 try: … … 96 97 del kwds['style'] 97 98 CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) 98 self.root = self.AddRoot( "Available Data")99 self.root = self.AddRoot(root) 99 100 100 101 def OnCompareItems(self, item1, item2): … … 114 115 return 0 115 116 117 116 118 class DataPanel(ScrolledPanel, PanelBase): 117 119 """ … … 119 121 interact with data. 120 122 """ 121 # #Internal name for the AUI manager123 # Internal name for the AUI manager 122 124 window_name = "Data Panel" 123 # #Title to appear on top of the window125 # Title to appear on top of the window 124 126 window_caption = "Data Explorer" 125 # type of window127 # type of window 126 128 window_type = "Data Panel" 127 # #Flag to tell the GUI manager that this panel is not129 # Flag to tell the GUI manager that this panel is not 128 130 # tied to any perspective 129 #ALWAYS_ON = True 131 # ALWAYS_ON = True 132 130 133 def __init__(self, parent, 131 134 list=None, … … 133 136 id=-1, 134 137 list_of_perspective=None, manager=None, *args, **kwds): 135 # kwds['size'] = size136 # kwds['style'] = STYLE_FLAG138 # kwds['size'] = size 139 # kwds['style'] = STYLE_FLAG 137 140 ScrolledPanel.__init__(self, parent=parent, id=id, *args, **kwds) 138 141 PanelBase.__init__(self, parent) 139 142 self.SetupScrolling() 140 # Set window's font size143 # Set window's font size 141 144 self.SetWindowVariant(variant=FONT_VARIANT) 142 145 self.loader = Loader() 143 # Default location146 # Default location 144 147 self._default_save_location = None 145 148 self.all_data1d = True … … 159 162 self.tree_ctrl_theory = None 160 163 self.perspective_cbox = None 161 # #Create context menu for page164 # Create context menu for page 162 165 self.data_menu = None 163 166 self.popUpMenu = None … … 165 168 self.editmask_id = None 166 169 # Default attr 167 self.vbox 170 self.vbox = None 168 171 self.sizer1 = None 169 172 self.sizer2 = None … … 210 213 """ 211 214 w, h = self.parent.GetSize() 212 self.vbox 215 self.vbox = wx.BoxSizer(wx.VERTICAL) 213 216 self.sizer1 = wx.BoxSizer(wx.VERTICAL) 214 217 self.sizer1.SetMinSize(wx.Size(w/13, h*2/5)) … … 219 222 self.sizer5 = wx.BoxSizer(wx.VERTICAL) 220 223 221 self.vbox.Add(self.sizer5, 0, wx.EXPAND |wx.ALL, 1)222 self.vbox.Add(self.sizer1, 1, wx.EXPAND |wx.ALL, 0)223 self.vbox.Add(self.sizer2, 0, wx.EXPAND |wx.ALL, 1)224 self.vbox.Add(self.sizer3, 0, wx.EXPAND |wx.ALL, 10)225 # self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5)224 self.vbox.Add(self.sizer5, 0, wx.EXPAND | wx.ALL, 1) 225 self.vbox.Add(self.sizer1, 1, wx.EXPAND | wx.ALL, 0) 226 self.vbox.Add(self.sizer2, 0, wx.EXPAND | wx.ALL, 1) 227 self.vbox.Add(self.sizer3, 0, wx.EXPAND | wx.ALL, 10) 228 # self.vbox.Add(self.sizer4, 0, wx.EXPAND|wx.ALL,5) 226 229 227 230 self.SetSizer(self.vbox) … … 235 238 self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 236 239 list_of_options = ['Select all Data', 237 240 'Unselect all Data', 238 241 'Select all Data 1D', 239 242 'Unselect all Data 1D', 240 243 'Select all Data 2D', 241 'Unselect all Data 2D' 244 'Unselect all Data 2D'] 242 245 for option in list_of_options: 243 246 self.selection_cbox.Append(str(option)) … … 245 248 wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type) 246 249 self.sizer5.AddMany([(select_txt, 0, wx.ALL, 5), 247 (self.selection_cbox, 0, wx.ALL, 5)])250 (self.selection_cbox, 0, wx.ALL, 5)]) 248 251 self.enable_selection() 249 250 252 251 253 def _on_selection_type(self, event): … … 257 259 self.tree_ctrl.CheckItem(data_ctrl, check_value) 258 260 if data_ctrl.HasChildren(): 259 if check_value == Trueand not control.IsExpanded():261 if check_value and not control.IsExpanded(): 260 262 # Only select children if control is expanded 261 263 # Always deselect children, regardless (see ticket #259) … … 299 301 Layout widgets related to buttons 300 302 """ 301 # Load Data Button303 # Load Data Button 302 304 self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 303 305 size=(BUTTON_WIDTH, -1)) … … 305 307 wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) 306 308 307 # Delete Data Button309 # Delete Data Button 308 310 self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data", 309 size=(BUTTON_WIDTH, -1))311 size=(BUTTON_WIDTH, -1)) 310 312 self.bt_remove.SetToolTipString("Delete data from the application") 311 313 wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 312 314 313 # Send data to perspective button315 # Send data to perspective button 314 316 self.bt_import = wx.Button(self, wx.NewId(), "Send To", 315 317 size=(BUTTON_WIDTH, -1)) 316 318 self.bt_import.SetToolTipString("Send Data set to active perspective") 317 319 wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 318 320 319 # Choose perspective to be send data to combo box321 # Choose perspective to be send data to combo box 320 322 self.perspective_cbox = wx.ComboBox(self, -1, 321 style=wx.CB_READONLY)323 style=wx.CB_READONLY) 322 324 if not IS_MAC: 323 325 self.perspective_cbox.SetMinSize((BUTTON_WIDTH*1.6, -1)) … … 325 327 self._on_perspective_selection) 326 328 327 # Append data to current Graph Button329 # Append data to current Graph Button 328 330 self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", 329 331 size=(BUTTON_WIDTH, -1)) 330 self.bt_append_plot.SetToolTipString( \331 332 self.bt_append_plot.SetToolTipString( 333 "Plot the selected data in the active panel") 332 334 wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 333 335 334 # Create a new graph and send data to that new graph button336 # Create a new graph and send data to that new graph button 335 337 self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", 336 338 size=(BUTTON_WIDTH, -1)) … … 338 340 wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 339 341 340 # Freeze current theory button - becomes a data set and stays on graph342 # Freeze current theory button - becomes a data set and stays on graph 341 343 self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", 342 344 size=(BUTTON_WIDTH, -1)) … … 347 349 wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 348 350 349 # select plot to send to combo box (blank if no data)351 # select plot to send to combo box (blank if no data) 350 352 if sys.platform == 'darwin': 351 353 self.cb_plotpanel = wx.ComboBox(self, -1, … … 353 355 else: 354 356 self.cb_plotpanel = wx.ComboBox(self, -1, 355 style=wx.CB_READONLY |wx.CB_SORT)357 style=wx.CB_READONLY | wx.CB_SORT) 356 358 wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) 357 359 self.cb_plotpanel.Disable() 358 360 359 # Help button361 # Help button 360 362 self.bt_help = wx.Button(self, wx.NewId(), "HELP", 361 363 size=(BUTTON_WIDTH, -1)) 362 364 self.bt_help.SetToolTipString("Help for the Data Explorer.") 363 wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help)365 wx.EVT_BUTTON(self, self.bt_help.GetId(), self.on_help) 364 366 365 367 self.sizer3.AddMany([(self.bt_add), … … 373 375 (self.bt_append_plot), 374 376 (self.cb_plotpanel, 375 wx.EXPAND |wx.ADJUST_MINSIZE, 5),377 wx.EXPAND | wx.ADJUST_MINSIZE, 5), 376 378 ((5, 5)), 377 379 ((5, 5)), 378 (self.bt_import, 0, wx.EXPAND |wx.RIGHT, 5),380 (self.bt_import, 0, wx.EXPAND | wx.RIGHT, 5), 379 381 (self.perspective_cbox, 380 wx.EXPAND |wx.ADJUST_MINSIZE, 5),382 wx.EXPAND | wx.ADJUST_MINSIZE, 5), 381 383 ((10, 10)), 382 384 (self.sizer4), … … 401 403 self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') 402 404 self.Bind(wx.EVT_RADIOBUTTON, self.on_single_mode, 403 405 id=self.rb_single_mode.GetId()) 404 406 self.Bind(wx.EVT_RADIOBUTTON, self.on_batch_mode, 405 407 id=self.rb_batch_mode.GetId()) 406 408 407 409 self.rb_single_mode.SetValue(not self.parent.batch_on) … … 433 435 """ 434 436 data = None 435 # selection = event.GetSelection()437 # selection = event.GetSelection() 436 438 id, _, _ = self.FindFocus().GetSelection().GetData() 437 439 data_list, theory_list = \ 438 440 self.parent.get_data_manager().get_by_id(id_list=[id]) 439 441 if data_list: 440 442 data = data_list.values()[0] 441 if data ==None:443 if data is None: 442 444 data = theory_list.values()[0][0] 443 445 return data … … 461 463 data = self._get_data_selection(event) 462 464 from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 463 import FloatPanel as Float3dDialog465 import FloatPanel as Float3dDialog 464 466 465 467 panel = Float3dDialog(base=self, data=data, … … 476 478 else: 477 479 dimension = 1 478 # panel = QucikPlotDialog(base=self, data=data,480 # panel = QucikPlotDialog(base=self, data=data, 479 481 # dimension=dimension, id=wx.NewId()) 480 482 frame = QucikPlotDialog(self, -1, "Plot " + data.name, 'log_{10}') 481 483 self.parent.put_icon(frame) 482 484 frame.add_plot(data) 483 # frame.SetTitle(title)485 # frame.SetTitle(title) 484 486 frame.Show(True) 485 487 frame.SetFocus() 486 # panel.ShowModal()488 # panel.ShowModal() 487 489 488 490 def on_data_info(self, event): … … 501 503 """ 502 504 data = self._get_data_selection(event) 503 # path = None505 # path = None 504 506 default_name = data.name 505 507 if default_name.count('.') > 0: 506 508 default_name = default_name.split('.')[0] 507 509 default_name += "_out" 508 if self.parent !=None:510 if self.parent is not None: 509 511 if issubclass(data.__class__, Data1D): 510 512 self.parent.save_data1d(data, default_name) … … 518 520 Add a listcrtl in the panel 519 521 """ 520 tree_ctrl_label = wx.StaticText(self, -1, "Data") 521 tree_ctrl_label.SetForegroundColour('blue') 522 self.tree_ctrl = DataTreeCtrl(parent=self, style=wx.SUNKEN_BORDER) 522 # Add splitter 523 w, h = self.parent.GetSize() 524 splitter = wx.SplitterWindow(self) 525 splitter.SetMinimumPaneSize(50) 526 splitter.SetSashGravity(1.0) 527 528 file_sizer = wx.BoxSizer(wx.VERTICAL) 529 file_sizer.SetMinSize(wx.Size(w/13, h*2/5)) 530 theory_sizer = wx.BoxSizer(wx.VERTICAL) 531 theory_sizer.SetMinSize(wx.Size(w/13, h*2/5)) 532 533 self.tree_ctrl = DataTreeCtrl(parent=splitter, 534 style=wx.SUNKEN_BORDER, 535 root="Available Data") 536 523 537 self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) 524 538 self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data) 525 # #Create context menu for page539 # Create context menu for page 526 540 self.data_menu = wx.Menu() 527 541 id = wx.NewId() … … 555 569 wx.EVT_MENU(self, self.editmask_id, self.on_edit_data) 556 570 557 tree_ctrl_theory_label = wx.StaticText(self, -1, "Theory") 558 tree_ctrl_theory_label.SetForegroundColour('blue') 559 self.tree_ctrl_theory = DataTreeCtrl(parent=self, 560 style=wx.SUNKEN_BORDER) 571 self.tree_ctrl_theory = DataTreeCtrl(parent=splitter, 572 style=wx.SUNKEN_BORDER, 573 root="Available Theory") 561 574 self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, 562 575 self.on_check_item) 563 576 self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU, 564 577 self.on_right_click_theory) 565 self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) 566 self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10) 567 self.sizer1.Add(tree_ctrl_theory_label, 0, wx.LEFT, 10) 568 self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND|wx.ALL, 10) 578 splitter.SplitHorizontally(self.tree_ctrl, self.tree_ctrl_theory) 579 self.sizer1.Add(splitter, 1, wx.EXPAND | wx.ALL, 10) 569 580 570 581 def on_right_click_theory(self, event): … … 588 599 Allow Editing Data 589 600 """ 590 # selection = event.GetSelection()601 # selection = event.GetSelection() 591 602 is_data = True 592 603 try: 593 604 id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() 594 605 data_list, _ = \ 595 606 self.parent.get_data_manager().get_by_id(id_list=[id]) 596 607 if not data_list: 597 608 is_data = False … … 610 621 """ 611 622 # Skipping the save state functionality for release 0.9.0 612 # return623 # return 613 624 pos = event.GetPosition() 614 625 pos = self.ScreenToClient(pos) 615 626 self.PopupMenu(self.popUpMenu, pos) 616 617 627 618 628 def on_check_item(self, event): … … 636 646 if self.parent is None or \ 637 647 not hasattr(self.parent, "get_current_perspective") or \ 638 len(self.list_of_perspective) == 0:648 len(self.list_of_perspective) == 0: 639 649 return 640 if self.parent is not None and self.perspective_cbox 650 if self.parent is not None and self.perspective_cbox is not None: 641 651 for plug in self.list_of_perspective: 642 652 if plug.get_perspective(): … … 666 676 s_path = str(path) 667 677 if state_id not in self.list_cb_data: 668 # new state678 # new state 669 679 data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, 670 0, data_name, ct_type=1, 680 0, data_name, 681 ct_type=1, 671 682 data=(data_id, data_class, state_id)) 672 683 data_c.Check(True) 673 684 d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 674 685 d_t_c = self.tree_ctrl.AppendItem(d_i_c, 675 'Title: %s' % data_title) 686 'Title: %s' % 687 data_title) 676 688 r_n_c = self.tree_ctrl.AppendItem(d_i_c, 677 'Run: %s' % data_run)689 'Run: %s' % data_run) 678 690 i_c_c = self.tree_ctrl.AppendItem(d_i_c, 679 'Type: %s' % data_class) 691 'Type: %s' % 692 data_class) 680 693 p_c_c = self.tree_ctrl.AppendItem(d_i_c, 681 "Path: '%s'" % s_path)694 "Path: '%s'" % s_path) 682 695 d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 683 696 684 697 for process in process_list: 685 process_str = str(process).replace('\n', ' ')686 if len(process_str) >20:687 process_str = process_str[:20] +' [...]'698 process_str = str(process).replace('\n', ' ') 699 if len(process_str) > 20: 700 process_str = process_str[:20] + ' [...]' 688 701 self.tree_ctrl.AppendItem(d_p_c, process_str) 689 702 theory_child = self.tree_ctrl.AppendItem(data_c, … … 698 711 theory_child] 699 712 else: 700 data_ctrl_list = 701 # This state is already display replace it contains713 data_ctrl_list = self.list_cb_data[state_id] 714 # This state is already display replace it contains 702 715 data_c, d_i_c, d_t_c, r_n_c, i_c_c, p_c_c, d_p_c, _ \ 703 716 = data_ctrl_list … … 713 726 if not process.is_empty(): 714 727 _ = self.tree_ctrl.AppendItem(d_p_c, 715 728 process.single_line_desc()) 716 729 wx.CallAfter(self.append_theory, state_id, theory_list) 717 730 # Sort by data name 718 731 if self.tree_ctrl.root: 719 732 self.tree_ctrl.SortChildren(self.tree_ctrl.root) 733 # Expand root if # of data sets > 0 734 if self.tree_ctrl.GetCount() > 0: 735 self.tree_ctrl.root.Expand() 720 736 self.enable_remove() 721 737 self.enable_import() … … 756 772 state_id=state_id, 757 773 theory_list=theory_list) 758 774 if self.tree_ctrl_theory.GetCount() > 0: 775 self.tree_ctrl_theory.root.Expand() 759 776 760 777 def append_theory_helper(self, tree, root, state_id, theory_list): … … 763 780 """ 764 781 if state_id in self.list_cb_theory.keys(): 765 # update current list of theory for this data782 # update current list of theory for this data 766 783 theory_list_ctrl = self.list_cb_theory[state_id] 767 784 … … 777 794 theory_class = theory_data.__class__.__name__ 778 795 theory_id = theory_data.id 779 # if theory_state is not None:796 # if theory_state is not None: 780 797 # name = theory_state.model.name 781 798 temp = (theory_id, theory_class, state_id) 782 799 if theory_id not in theory_list_ctrl: 783 # add new theory800 # add new theory 784 801 t_child = tree.AppendItem(root, 785 802 name, ct_type=1, data=temp) … … 795 812 t_p_c] 796 813 else: 797 # replace theory814 # replace theory 798 815 t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] 799 816 tree.SetItemText(t_child, name) … … 805 822 806 823 else: 807 # data didn't have a theory associated it before824 # data didn't have a theory associated it before 808 825 theory_list_ctrl = {} 809 826 for theory_id, item in theory_list.iteritems(): … … 813 830 theory_class = theory_data.__class__.__name__ 814 831 theory_id = theory_data.id 815 # if theory_state is not None:832 # if theory_state is not None: 816 833 # name = theory_state.model.name 817 834 temp = (theory_id, theory_class, state_id) … … 828 845 829 846 theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 830 # self.list_cb_theory[data_id] = theory_list_ctrl847 # self.list_cb_theory[data_id] = theory_list_ctrl 831 848 self.list_cb_theory[state_id] = theory_list_ctrl 832 833 834 849 835 850 def set_data_helper(self): … … 889 904 wx.PostEvent(self.parent, NewLoadDataEvent()) 890 905 891 892 def on_remove(self, event): 906 def on_remove(self, event, prompt=True): 893 907 """ 894 908 Get a list of item checked and remove them from the treectrl 895 909 Ask the parent to remove reference to this item 896 910 """ 897 msg = "This operation will delete the data sets checked " 898 msg += "and all the dependents." 899 msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) 900 if msg_box.ShowModal() != wx.ID_OK: 901 return 911 if prompt: 912 msg = "This operation will delete the data sets checked " 913 msg += "and all the dependents." 914 msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) 915 if msg_box.ShowModal() != wx.ID_OK: 916 return 902 917 903 918 data_to_remove, theory_to_remove, _ = self.set_data_helper() 904 919 data_key = [] 905 920 theory_key = [] 906 # remove data from treectrl921 # remove data from treectrl 907 922 for d_key, item in self.list_cb_data.iteritems(): 908 923 data_c, _, _, _, _, _, _, _ = item … … 915 930 # Remove theory from treectrl 916 931 for _, theory_dict in self.list_cb_theory.iteritems(): 917 for 932 for key, value in theory_dict.iteritems(): 918 933 item, _, _ = value 919 934 if item.IsChecked(): … … 924 939 theory_key.append(key) 925 940 926 # Remove data and related theory references941 # Remove data and related theory references 927 942 for key in data_key: 928 943 del self.list_cb_data[key] 929 944 if key in theory_key: 930 945 del self.list_cb_theory[key] 931 # remove theory references independently of data946 # remove theory references independently of data 932 947 for key in theory_key: 933 948 for _, theory_dict in self.list_cb_theory.iteritems(): 934 949 if key in theory_dict: 935 for 950 for key, value in theory_dict.iteritems(): 936 951 item, _, _ = value 937 952 if item.IsChecked(): … … 942 957 del theory_dict[key] 943 958 944 945 959 self.parent.remove_data(data_id=data_to_remove, 946 960 theory_id=theory_to_remove) … … 953 967 Get all select data and set them to the current active perspetive 954 968 """ 955 if event !=None:969 if event is not None: 956 970 event.Skip() 957 971 data_id, theory_id, state_id = self.set_data_helper() … … 985 999 On close 986 1000 """ 987 if event !=None:1001 if event is not None: 988 1002 event.Skip() 989 1003 # send parent to update menu with no show nor hide action … … 1015 1029 from the combobox of the current panel 1016 1030 """ 1017 # name = event.name1031 # name = event.name 1018 1032 caption = event.caption 1019 1033 if self.cb_plotpanel is not None: … … 1033 1047 if name_plot_panel not in self.cb_plotpanel.GetItems(): 1034 1048 self.cb_plotpanel.Append(name_plot_panel, value) 1035 if name !=None and name == name_plot_panel:1049 if name is not None and name == name_plot_panel: 1036 1050 self.cb_plotpanel.SetStringSelection(name_plot_panel) 1037 1051 break … … 1059 1073 On source combobox selection 1060 1074 """ 1061 if event !=None:1075 if event is not None: 1062 1076 combo = event.GetEventObject() 1063 1077 event.Skip() … … 1106 1120 running "file:///...." 1107 1121 1108 :param ev t: Triggers on clicking the help button1122 :param event: Triggers on clicking the help button 1109 1123 """ 1110 1124 … … 1155 1169 """ 1156 1170 n_t = 0 1157 if self.tree_ctrl !=None:1171 if self.tree_ctrl is not None: 1158 1172 n_t = self.tree_ctrl.GetCount() 1159 1173 if n_t > 0 and len(self.list_of_perspective) > 0: … … 1174 1188 n_t = 0 1175 1189 n_t_t = 0 1176 if self.tree_ctrl !=None:1190 if self.tree_ctrl is not None: 1177 1191 n_t = self.tree_ctrl.GetCount() 1178 if self.tree_ctrl_theory !=None:1192 if self.tree_ctrl_theory is not None: 1179 1193 n_t_t = self.tree_ctrl_theory.GetCount() 1180 1194 if n_t + n_t_t <= 0: … … 1190 1204 n_t = 0 1191 1205 n_t_t = 0 1192 if self.tree_ctrl !=None:1206 if self.tree_ctrl is not None: 1193 1207 n_t = self.tree_ctrl.GetCount() 1194 if self.tree_ctrl_theory !=None:1208 if self.tree_ctrl_theory is not None: 1195 1209 n_t_t = self.tree_ctrl_theory.GetCount() 1196 1210 if n_t + n_t_t <= 0: … … 1214 1228 n_t_t = 0 1215 1229 n_l = 0 1216 if self.tree_ctrl_theory !=None:1230 if self.tree_ctrl_theory is not None: 1217 1231 n_t_t = self.tree_ctrl_theory.GetCount() 1218 1232 n_l = len(self.list_cb_theory) … … 1228 1242 n_t = 0 1229 1243 n_t_t = 0 1230 if self.tree_ctrl !=None:1244 if self.tree_ctrl is not None: 1231 1245 n_t = self.tree_ctrl.GetCount() 1232 if self.tree_ctrl_theory !=None:1246 if self.tree_ctrl_theory is not None: 1233 1247 n_t_t = self.tree_ctrl_theory.GetCount() 1234 if n_t + n_t_t > 0 and self.selection_cbox !=None:1248 if n_t + n_t_t > 0 and self.selection_cbox is not None: 1235 1249 self.selection_cbox.Enable() 1236 1250 else: … … 1254 1268 #self.bt_remove.Hide() 1255 1269 self.bt_add.Hide() 1256 1257 1270 1258 1271 … … 1287 1300 if not data_list or len(data_list) <= 1: 1288 1301 return 1289 # add text1302 # add text 1290 1303 1291 1304 text = "Deleting these file reset some panels.\n" … … 1295 1308 iy = 0 1296 1309 ix = 0 1297 # data_count = 01310 # data_count = 0 1298 1311 for (data_name, in_use, sub_menu) in range(len(data_list)): 1299 if in_use == True:1312 if in_use: 1300 1313 ctrl_name = wx.StaticBox(self, -1, str(data_name)) 1301 1314 ctrl_in_use = wx.StaticBox(self, -1, " is used by ") 1302 1315 plug_name = str(sub_menu) + "\n" 1303 # ctrl_sub_menu = wx.StaticBox(self, -1, plug_name)1316 # ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 1304 1317 self.sizer.Add(ctrl_name, (iy, ix), 1305 1318 (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) … … 1312 1325 iy += 1 1313 1326 self._panel.SetSizer(self.sizer) 1314 # add sizer1327 # add sizer 1315 1328 self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 1316 1329 button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") … … 1375 1388 1376 1389 1377 1378 1390 from sas.sasgui.guiframe.dataFitting import Theory1D 1379 1391 from sas.sasgui.guiframe.data_state import DataState 1392 1380 1393 1381 1394 class State(): … … 1391 1404 return self.msg 1392 1405 1406 1393 1407 def set_data_state(data=None, path=None, theory=None, state=None): 1394 1408 """ … … 1405 1419 app = wx.App() 1406 1420 try: 1407 # list_of_perspective = [('perspective2', False), ('perspective1', True)]1421 # list_of_perspective = [('perspective2', False), ('perspective1', True)] 1408 1422 data_list1 = {} 1409 1423 # state 1 … … 1420 1434 state1 = State() 1421 1435 data_list1['1'] = set_data_state(data1, path1, theory1, state1) 1422 # state 21436 # state 2 1423 1437 data1 = Data2D() 1424 1438 data1.name = "data2" … … 1428 1442 theory1.name = "CoreShell 07/24/25" 1429 1443 path1 = "path2" 1430 # state31444 # state3 1431 1445 state1 = State() 1432 1446 data_list1['2'] = set_data_state(data1, path1, theory1, state1) … … 1445 1459 process1.data = "07/22/2010" 1446 1460 data_list1['4'] = set_data_state(data1, path1, theory1, state1) 1447 # state 41461 # state 4 1448 1462 temp_data_list = {} 1449 1463 data1.name = "data5 erasing data2" 1450 1464 temp_data_list['4'] = set_data_state(data1, path1, theory1, state1) 1451 # state 51465 # state 5 1452 1466 data1 = Data2D() 1453 1467 data1.name = "data3" … … 1482 1496 window.load_data_list(list=temp_data_list) 1483 1497 except: 1484 # raise1498 # raise 1485 1499 print "error", sys.exc_value 1486 1500
Note: See TracChangeset
for help on using the changeset viewer.