Changeset 600eca2 in sasview
- Timestamp:
- Apr 27, 2011 5:43:47 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:
- 93f7c62
- Parents:
- f5bdb4a
- Location:
- guiframe
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_panel.py
r61ffd1e r600eca2 22 22 from sans.guiframe.events import StatusEvent 23 23 from DataLoader.loader import Loader 24 import logging 24 25 25 26 try: … … 88 89 # tied to any perspective 89 90 #ALWAYS_ON = True 90 def __init__(self, parent, list=[],list_of_perspective=[], 91 def __init__(self, parent, 92 list=None, 93 list_of_perspective=None, 91 94 size=(PANEL_WIDTH,PANEL_HEIGHT), manager=None, *args, **kwds): 92 95 kwds['size']= size … … 101 104 self.parent = parent 102 105 self.manager = manager 106 if list is None: 107 list = [] 103 108 self.list_of_data = list 109 if list_of_perspective is None: 110 list_of_perspective = [] 104 111 self.list_of_perspective = list_of_perspective 105 112 self.list_rb_perspectives= [] … … 108 115 self.tree_ctrl = None 109 116 self.tree_ctrl_theory = None 117 self.perspective_cbox = None 110 118 111 119 self.owner = None 112 120 self.do_layout() 121 self.fill_cbox_analysis(self.list_of_perspective) 113 122 self.Bind(wx.EVT_SHOW, self.on_close_page) 114 123 … … 121 130 self.layout_data_list() 122 131 self.layout_button() 123 self.layout_batch()132 #self.layout_batch() 124 133 125 134 def define_panel_structure(self): … … 133 142 134 143 self.sizer2 = wx.BoxSizer(wx.VERTICAL) 135 self.sizer3 = wx.GridBagSizer(5,5) 144 #self.sizer3 = wx.GridBagSizer(5,5) 145 self.sizer3 = wx.FlexGridSizer(5, 2, 0, 0) 136 146 self.sizer4 = wx.BoxSizer(wx.HORIZONTAL) 137 147 self.sizer5 = wx.BoxSizer(wx.VERTICAL) … … 275 285 self.bt_import.SetToolTipString("Send set of Data to active perspective") 276 286 wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 277 287 self.perspective_cbox = wx.ComboBox(self, -1, 288 style=wx.CB_READONLY) 289 wx.EVT_COMBOBOX(self.perspective_cbox,-1, 290 self._on_perspective_selection) 291 278 292 self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") 279 293 self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") … … 288 302 wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 289 303 290 self.tctrl_perspective = wx.StaticText(self, -1, 291 'No Active Application', 292 style=wx.SUNKEN_BORDER|wx.ALIGN_LEFT) 293 self.tctrl_perspective.SetToolTipString("Active Application") 294 perspective_font = self.tctrl_perspective.GetFont() 295 perspective_font.SetWeight(wx.BOLD) 296 self.tctrl_perspective.SetFont(perspective_font) 297 self.tctrl_perspective.SetClientSize((80,20)) 304 305 #self.tctrl_perspective.SetToolTipString("Active Application") 306 #perspective_font = self.tctrl_perspective.GetFont() 307 #perspective_font.SetWeight(wx.BOLD) 308 #self.tctrl_perspective.SetFont(perspective_font) 309 #self.tctrl_perspective.SetClientSize((80,20)) 298 310 self.cb_plotpanel = wx.ComboBox(self, -1, 299 311 style=wx.CB_READONLY|wx.CB_SORT) … … 305 317 #self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") 306 318 319 320 self.sizer3.AddMany([(self.bt_add), 321 ((10, 10)), 322 (self.bt_import), 323 (self.perspective_cbox, wx.EXPAND), 324 (self.bt_append_plot), 325 (self.cb_plotpanel, wx.EXPAND), 326 (self.bt_plot), 327 ((10, 10)), 328 (self.bt_freeze)]) 329 self.sizer3.AddGrowableCol(1, 1) 330 331 """ 307 332 ix = 0 308 333 iy = 0 … … 316 341 self.sizer3.Add(self.bt_import,( iy, ix),(1,1), 317 342 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 343 318 344 ix += 1 319 self.sizer3.Add(self. tctrl_perspective,(iy, ix),(1,1),345 self.sizer3.Add(self.perspective_cbox,(iy, ix),(1,1), 320 346 wx.EXPAND|wx.ADJUST_MINSIZE, 0) 321 347 ix = 0 … … 334 360 self.sizer3.Add(self.bt_freeze,( iy, ix),(1,1), 335 361 wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 5) 336 self.enable_remove() 362 """ 363 #self.enable_remove() 337 364 self.enable_import() 338 365 self.enable_plot() … … 343 370 """ 344 371 """ 345 return346 372 self.rb_single_mode = wx.RadioButton(self, -1, 'Single Mode', 347 373 style=wx.RB_GROUP) … … 353 379 (self.rb_batch_mode,0, wx.ALL,5)]) 354 380 355 def old_layout_data_list(self):356 """357 Add a listcrtl in the panel358 """359 self.tree_ctrl = DataTreeCtrl(parent=self)360 self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item)361 self.sizer1.Add(self.tree_ctrl,1, wx.EXPAND|wx.ALL, 10)362 self.theory_root = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0,363 "THEORIES", ct_type=0)364 365 381 def layout_data_list(self): 366 382 """ … … 396 412 item = event.GetItem() 397 413 item.Check(not item.IsChecked()) 398 self.enable_button(item)399 414 event.Skip() 400 415 401 def enable_button(self, item): 402 """ 403 """ 404 # Not implemented 405 return 406 """ 407 _, data_class, _= self.tree_ctrl.GetItemPyData(item) 408 if item.IsChecked(): 409 self.all_data1d &= (data_class != "Data2D") 410 if self.all_data1d: 411 self.bt_freeze.Enable() 412 else: 413 self.bt_freeze.Disable() 414 else: 415 self.all_data1d |= True 416 self.all_data1d &= (data_class != "Data2D") 417 if self.all_data1d: 418 self.bt_freeze.Enable() 419 else: 420 self.bt_freeze.Disable() 421 """ 416 def fill_cbox_analysis(self, plugin): 417 """ 418 fill the combobox with analysis name 419 """ 420 self.list_of_perspective = plugin 421 if self.parent is None or \ 422 not hasattr(self.parent, "get_current_perspective") or \ 423 len(self.list_of_perspective) == 0: 424 return 425 if self.parent is not None and self.perspective_cbox is not None: 426 for plug in self.list_of_perspective: 427 if plug.get_perspective(): 428 self.perspective_cbox.Append(plug.sub_menu, plug) 429 430 curr_pers = self.parent.get_current_perspective() 431 self.perspective_cbox.SetStringSelection(curr_pers.sub_menu) 432 self.enable_import() 433 422 434 def load_data_list(self, list): 423 435 """ … … 441 453 data=(data_id, data_class, state_id)) 442 454 data_c.Check(True) 443 self.enable_button(data_c)444 455 d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 445 456 i_c_c = self.tree_ctrl.AppendItem(d_i_c, … … 474 485 process.__str__()) 475 486 self.append_theory(state_id, theory_list) 476 self.enable_remove()487 #self.enable_remove() 477 488 self.enable_import() 478 489 self.enable_plot() … … 488 499 self.tree_ctrl.CheckItem(data_ctrl, False) 489 500 490 def old_append_theory(self, state_id, theory_list): 491 """ 492 append theory object under data from a state of id = state_id 493 replace that theory if already displayed 494 """ 495 if not theory_list: 496 return 497 if state_id not in self.list_cb_data.keys(): 498 root = self.theory_root 499 else: 500 item = self.list_cb_data[state_id] 501 data_c, _, _, _, _, _ = item 502 root = data_c 503 if root is not None: 504 self.append_theory_helper(root=root, 505 state_id=state_id, 506 theory_list=theory_list) 501 507 502 def append_theory(self, state_id, theory_list): 508 503 """ … … 779 774 self.parent.remove_data(data_id=data_to_remove, 780 775 theory_id=theory_to_remove) 781 self.enable_remove()776 #self.enable_remove() 782 777 self.enable_freeze() 783 778 … … 832 827 set the active perspective 833 828 """ 834 self.tctrl_perspective.SetLabel(str(name)) 835 #perspective_font = self.tctrl_perspective.GetFont() 836 #perspective_font.SetWeight(wx.BOLD) 837 self.tctrl_perspective.SetClientSize((80,20))#SetFont(perspective_font) 829 self.perspective_cbox.SetStringSelection(name) 838 830 self.enable_import() 839 831 … … 848 840 self.cb_plotpanel.SetStringSelection(name_plot_panel) 849 841 self.enable_append() 850 842 843 def _on_perspective_selection(self, event=None): 844 """ 845 select the current perspective for guiframe 846 """ 847 selection = self.perspective_cbox.GetSelection() 848 849 if self.perspective_cbox.GetValue() != 'None': 850 perspective = self.perspective_cbox.GetClientData(selection) 851 perspective.on_perspective(event=None) 852 851 853 def _on_plot_selection(self, event = None): 852 854 """ … … 868 870 enable or disable remove button 869 871 """ 870 return871 872 n_t = self.tree_ctrl.GetCount() 872 873 n_t_t = self.tree_ctrl_theory.GetCount() … … 883 884 if self.tree_ctrl != None: 884 885 n_t = self.tree_ctrl.GetCount() 885 if n_t <=0 or self.tctrl_perspective.GetLabelText() == "No Active Application": 886 if n_t > 0 and len(self.list_of_perspective) > 0: 887 self.bt_import.Enable() 888 else: 886 889 self.bt_import.Disable() 890 if len(self.list_of_perspective) <= 0 or \ 891 self.perspective_cbox.GetValue() in ["None", 892 "No Active Application"]: 893 self.perspective_cbox.Disable() 887 894 else: 888 self. bt_import.Enable()895 self.perspective_cbox.Enable() 889 896 890 897 def enable_plot(self): … … 892 899 enable or disable plot button 893 900 """ 894 n_t = self.tree_ctrl.GetCount() 895 n_t_t = self.tree_ctrl_theory.GetCount() 901 n_t = 0 902 n_t_t = 0 903 if self.tree_ctrl != None: 904 n_t = self.tree_ctrl.GetCount() 905 if self.tree_ctrl_theory != None: 906 n_t_t = self.tree_ctrl_theory.GetCount() 896 907 if n_t + n_t_t <= 0: 897 908 self.bt_plot.Disable() … … 903 914 enable or disable append button 904 915 """ 905 if self.cb_plotpanel.GetValue() == 'None': 916 n_t = 0 917 n_t_t = 0 918 if self.tree_ctrl != None: 919 n_t = self.tree_ctrl.GetCount() 920 if self.tree_ctrl_theory != None: 921 n_t_t = self.tree_ctrl_theory.GetCount() 922 if n_t + n_t_t <= 0: 906 923 self.bt_append_plot.Disable() 924 self.cb_plotpanel.Disable() 925 elif self.cb_plotpanel.GetValue() == 'None': 926 self.bt_append_plot.Disable() 927 if self.cb_plotpanel.GetCount() <= 1: 928 self.cb_plotpanel.Disable() 929 else: 930 self.cb_plotpanel.Ensable() 907 931 else: 908 932 self.bt_append_plot.Enable() 933 self.cb_plotpanel.Ensable() 909 934 910 935 def enable_freeze(self): -
guiframe/gui_manager.py
r56d5562 r600eca2 187 187 188 188 189 def get_current_perspective(self): 190 """ 191 return the current perspective 192 """ 193 return self._current_perspective 194 189 195 def set_input_file(self, input_file): 190 196 """ … … 252 258 msg += str(sys.exc_value) + '\n' 253 259 print msg 260 if self._data_panel is not None: 261 self._data_panel.fill_cbox_analysis(self.plugins) 254 262 self.post_init() 255 263 #self.show_welcome_panel(None) … … 310 318 if not is_loaded: 311 319 self.plugins.append(plugin) 320 312 321 313 322 def _get_local_plugins(self):
Note: See TracChangeset
for help on using the changeset viewer.