Ignore:
Timestamp:
Apr 10, 2017 4:01:46 AM (8 years ago)
Author:
Piotr Rozyczko <rozyczko@…>
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.
Message:

Merge branch 'master' into ESS_GUI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/guiframe/data_panel.py

    rd6e36e44 r9687d58  
    11################################################################################ 
    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. 
     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. 
    55# 
    6 #See the license text in license.txt 
     6# See the license text in license.txt 
    77# 
    8 #copyright 2010, University of Tennessee 
     8# copyright 2010, University of Tennessee 
    99################################################################################ 
    1010""" 
     
    1414from wx.build import build_options 
    1515 
    16 # Check version 
    17 toks = str(wx.__version__).split('.') 
    18 if int(toks[1]) < 9: 
    19     if int(toks[2]) < 12: 
    20         wx_version = 811 
    21     else: 
    22         wx_version = 812 
    23 else: 
    24     wx_version = 900 
    2516import sys 
    2617from wx.lib.scrolledpanel import ScrolledPanel 
    27 import  wx.lib.agw.customtreectrl as CT 
     18import wx.lib.agw.customtreectrl as CT 
    2819from sas.sasgui.guiframe.dataFitting import Data1D 
    2920from sas.sasgui.guiframe.dataFitting import Data2D 
     
    3627from sas.sasgui.guiframe.events import NewBatchEvent 
    3728from sas.sascalc.dataloader.loader import Loader 
    38 #from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 
     29# from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 
    3930#    import FloatPanel as QucikPlotDialog 
    40 from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot import PlotFrame \ 
    41         as QucikPlotDialog 
     31from sas.sasgui.guiframe.local_perspectives.plotting.SimplePlot \ 
     32    import PlotFrame as QucikPlotDialog 
    4233import sas.sasgui.guiframe.config as config 
     34 
     35# Check version 
     36toks = str(wx.__version__).split('.') 
     37if int(toks[1]) < 9: 
     38    if int(toks[2]) < 12: 
     39        wx_version = 811 
     40    else: 
     41        wx_version = 812 
     42else: 
     43    wx_version = 900 
    4344 
    4445extension_list = [] 
     
    4950APPLICATION_WLIST = config.APPLICATION_WLIST 
    5051 
    51 #Control panel width 
     52# Control panel width 
    5253if sys.platform.count("win32") > 0: 
    5354    PANEL_WIDTH = 235 
     
    6566    IS_MAC = True 
    6667 
    67 STYLE_FLAG = wx.RAISED_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\ 
    68                     wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT 
     68STYLE_FLAG = (wx.RAISED_BORDER | CT.TR_HAS_BUTTONS | 
     69                    wx.WANTS_CHARS | CT.TR_HAS_VARIABLE_ROW_HEIGHT) 
    6970 
    7071 
     
    7374    Check list control to be used for Data Panel 
    7475    """ 
    75     def __init__(self, parent, *args, **kwds): 
    76         #agwstyle is introduced in wx.2.8.11 but is not working for mac 
     76    def __init__(self, parent, root, *args, **kwds): 
     77        # agwstyle is introduced in wx.2.8.11 but is not working for mac 
    7778        if IS_MAC and wx_version < 812: 
    7879            try: 
     
    9697                    del kwds['style'] 
    9798                    CT.CustomTreeCtrl.__init__(self, parent, *args, **kwds) 
    98         self.root = self.AddRoot("Available Data") 
     99        self.root = self.AddRoot(root) 
    99100 
    100101    def OnCompareItems(self, item1, item2): 
     
    114115            return 0 
    115116 
     117 
    116118class DataPanel(ScrolledPanel, PanelBase): 
    117119    """ 
     
    119121    interact with data. 
    120122    """ 
    121     ## Internal name for the AUI manager 
     123    # Internal name for the AUI manager 
    122124    window_name = "Data Panel" 
    123     ## Title to appear on top of the window 
     125    # Title to appear on top of the window 
    124126    window_caption = "Data Explorer" 
    125     #type of window 
     127    # type of window 
    126128    window_type = "Data Panel" 
    127     ## Flag to tell the GUI manager that this panel is not 
     129    # Flag to tell the GUI manager that this panel is not 
    128130    #  tied to any perspective 
    129     #ALWAYS_ON = True 
     131    # ALWAYS_ON = True 
     132 
    130133    def __init__(self, parent, 
    131134                 list=None, 
     
    133136                 id=-1, 
    134137                 list_of_perspective=None, manager=None, *args, **kwds): 
    135         #kwds['size'] = size 
    136         #kwds['style'] = STYLE_FLAG 
     138        # kwds['size'] = size 
     139        # kwds['style'] = STYLE_FLAG 
    137140        ScrolledPanel.__init__(self, parent=parent, id=id, *args, **kwds) 
    138141        PanelBase.__init__(self, parent) 
    139142        self.SetupScrolling() 
    140         #Set window's font size 
     143        # Set window's font size 
    141144        self.SetWindowVariant(variant=FONT_VARIANT) 
    142145        self.loader = Loader() 
    143         #Default location 
     146        # Default location 
    144147        self._default_save_location = None 
    145148        self.all_data1d = True 
     
    159162        self.tree_ctrl_theory = None 
    160163        self.perspective_cbox = None 
    161         ## Create context menu for page 
     164        # Create context menu for page 
    162165        self.data_menu = None 
    163166        self.popUpMenu = None 
     
    165168        self.editmask_id = None 
    166169        # Default attr 
    167         self.vbox  = None 
     170        self.vbox = None 
    168171        self.sizer1 = None 
    169172        self.sizer2 = None 
     
    210213        """ 
    211214        w, h = self.parent.GetSize() 
    212         self.vbox  = wx.BoxSizer(wx.VERTICAL) 
     215        self.vbox = wx.BoxSizer(wx.VERTICAL) 
    213216        self.sizer1 = wx.BoxSizer(wx.VERTICAL) 
    214217        self.sizer1.SetMinSize(wx.Size(w/13, h*2/5)) 
     
    219222        self.sizer5 = wx.BoxSizer(wx.VERTICAL) 
    220223 
    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) 
    226229 
    227230        self.SetSizer(self.vbox) 
     
    235238        self.selection_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    236239        list_of_options = ['Select all Data', 
    237                             'Unselect all Data', 
     240                           'Unselect all Data', 
    238241                           'Select all Data 1D', 
    239242                           'Unselect all Data 1D', 
    240243                           'Select all Data 2D', 
    241                            'Unselect all Data 2D' ] 
     244                           'Unselect all Data 2D'] 
    242245        for option in list_of_options: 
    243246            self.selection_cbox.Append(str(option)) 
     
    245248        wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type) 
    246249        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)]) 
    248251        self.enable_selection() 
    249  
    250252 
    251253    def _on_selection_type(self, event): 
     
    257259            self.tree_ctrl.CheckItem(data_ctrl, check_value) 
    258260            if data_ctrl.HasChildren(): 
    259                 if check_value == True and not control.IsExpanded(): 
     261                if check_value and not control.IsExpanded(): 
    260262                    # Only select children if control is expanded 
    261263                    # Always deselect children, regardless (see ticket #259) 
     
    299301        Layout widgets related to buttons 
    300302        """ 
    301         #Load Data Button 
     303        # Load Data Button 
    302304        self.bt_add = wx.Button(self, wx.NewId(), "Load Data", 
    303305                                size=(BUTTON_WIDTH, -1)) 
     
    305307        wx.EVT_BUTTON(self, self.bt_add.GetId(), self._load_data) 
    306308 
    307         #Delete Data Button 
     309        # Delete Data Button 
    308310        self.bt_remove = wx.Button(self, wx.NewId(), "Delete Data", 
    309          size=(BUTTON_WIDTH, -1)) 
     311                                   size=(BUTTON_WIDTH, -1)) 
    310312        self.bt_remove.SetToolTipString("Delete data from the application") 
    311313        wx.EVT_BUTTON(self, self.bt_remove.GetId(), self.on_remove) 
    312314 
    313         #Send data to perspective button 
     315        # Send data to perspective button 
    314316        self.bt_import = wx.Button(self, wx.NewId(), "Send To", 
    315                                     size=(BUTTON_WIDTH, -1)) 
     317                                   size=(BUTTON_WIDTH, -1)) 
    316318        self.bt_import.SetToolTipString("Send Data set to active perspective") 
    317319        wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 
    318320 
    319         #Choose perspective to be send data to combo box 
     321        # Choose perspective to be send data to combo box 
    320322        self.perspective_cbox = wx.ComboBox(self, -1, 
    321                                 style=wx.CB_READONLY) 
     323                                            style=wx.CB_READONLY) 
    322324        if not IS_MAC: 
    323325            self.perspective_cbox.SetMinSize((BUTTON_WIDTH*1.6, -1)) 
     
    325327                        self._on_perspective_selection) 
    326328 
    327         #Append data to current Graph Button 
     329        # Append data to current Graph Button 
    328330        self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", 
    329331                                        size=(BUTTON_WIDTH, -1)) 
    330         self.bt_append_plot.SetToolTipString( \ 
    331                                 "Plot the selected data in the active panel") 
     332        self.bt_append_plot.SetToolTipString( 
     333            "Plot the selected data in the active panel") 
    332334        wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 
    333335 
    334         #Create a new graph and send data to that new graph button 
     336        # Create a new graph and send data to that new graph button 
    335337        self.bt_plot = wx.Button(self, wx.NewId(), "New Plot", 
    336338                                 size=(BUTTON_WIDTH, -1)) 
     
    338340        wx.EVT_BUTTON(self, self.bt_plot.GetId(), self.on_plot) 
    339341 
    340         #Freeze current theory button - becomes a data set and stays on graph 
     342        # Freeze current theory button - becomes a data set and stays on graph 
    341343        self.bt_freeze = wx.Button(self, wx.NewId(), "Freeze Theory", 
    342344                                   size=(BUTTON_WIDTH, -1)) 
     
    347349        wx.EVT_BUTTON(self, self.bt_freeze.GetId(), self.on_freeze) 
    348350 
    349         #select plot to send to combo box (blank if no data) 
     351        # select plot to send to combo box (blank if no data) 
    350352        if sys.platform == 'darwin': 
    351353            self.cb_plotpanel = wx.ComboBox(self, -1, 
     
    353355        else: 
    354356            self.cb_plotpanel = wx.ComboBox(self, -1, 
    355                                             style=wx.CB_READONLY|wx.CB_SORT) 
     357                                            style=wx.CB_READONLY | wx.CB_SORT) 
    356358        wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) 
    357359        self.cb_plotpanel.Disable() 
    358360 
    359         #Help button 
     361        # Help button 
    360362        self.bt_help = wx.Button(self, wx.NewId(), "HELP", 
    361363                                 size=(BUTTON_WIDTH, -1)) 
    362364        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) 
    364366 
    365367        self.sizer3.AddMany([(self.bt_add), 
     
    373375                             (self.bt_append_plot), 
    374376                             (self.cb_plotpanel, 
    375                               wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
     377                              wx.EXPAND | wx.ADJUST_MINSIZE, 5), 
    376378                             ((5, 5)), 
    377379                             ((5, 5)), 
    378                              (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5), 
     380                             (self.bt_import, 0, wx.EXPAND | wx.RIGHT, 5), 
    379381                             (self.perspective_cbox, 
    380                               wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
     382                              wx.EXPAND | wx.ADJUST_MINSIZE, 5), 
    381383                             ((10, 10)), 
    382384                             (self.sizer4), 
     
    401403        self.rb_batch_mode = wx.RadioButton(self, -1, 'Batch Mode') 
    402404        self.Bind(wx.EVT_RADIOBUTTON, self.on_single_mode, 
    403                      id=self.rb_single_mode.GetId()) 
     405                  id=self.rb_single_mode.GetId()) 
    404406        self.Bind(wx.EVT_RADIOBUTTON, self.on_batch_mode, 
    405                    id=self.rb_batch_mode.GetId()) 
     407                  id=self.rb_batch_mode.GetId()) 
    406408 
    407409        self.rb_single_mode.SetValue(not self.parent.batch_on) 
     
    433435        """ 
    434436        data = None 
    435         #selection = event.GetSelection() 
     437        # selection = event.GetSelection() 
    436438        id, _, _ = self.FindFocus().GetSelection().GetData() 
    437439        data_list, theory_list = \ 
    438                         self.parent.get_data_manager().get_by_id(id_list=[id]) 
     440            self.parent.get_data_manager().get_by_id(id_list=[id]) 
    439441        if data_list: 
    440442            data = data_list.values()[0] 
    441         if data == None: 
     443        if data is None: 
    442444            data = theory_list.values()[0][0] 
    443445        return data 
     
    461463        data = self._get_data_selection(event) 
    462464        from sas.sasgui.guiframe.local_perspectives.plotting.masking \ 
    463         import FloatPanel as Float3dDialog 
     465            import FloatPanel as Float3dDialog 
    464466 
    465467        panel = Float3dDialog(base=self, data=data, 
     
    476478        else: 
    477479            dimension = 1 
    478         #panel = QucikPlotDialog(base=self, data=data, 
     480        # panel = QucikPlotDialog(base=self, data=data, 
    479481        #                        dimension=dimension, id=wx.NewId()) 
    480482        frame = QucikPlotDialog(self, -1, "Plot " + data.name, 'log_{10}') 
    481483        self.parent.put_icon(frame) 
    482484        frame.add_plot(data) 
    483         #frame.SetTitle(title) 
     485        # frame.SetTitle(title) 
    484486        frame.Show(True) 
    485487        frame.SetFocus() 
    486         #panel.ShowModal() 
     488        # panel.ShowModal() 
    487489 
    488490    def on_data_info(self, event): 
     
    501503        """ 
    502504        data = self._get_data_selection(event) 
    503         #path = None 
     505        # path = None 
    504506        default_name = data.name 
    505507        if default_name.count('.') > 0: 
    506508            default_name = default_name.split('.')[0] 
    507509        default_name += "_out" 
    508         if self.parent != None: 
     510        if self.parent is not None: 
    509511            if issubclass(data.__class__, Data1D): 
    510512                self.parent.save_data1d(data, default_name) 
     
    518520        Add a listcrtl in the panel 
    519521        """ 
    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 
    523537        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) 
    524538        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data) 
    525         ## Create context menu for page 
     539        # Create context menu for page 
    526540        self.data_menu = wx.Menu() 
    527541        id = wx.NewId() 
     
    555569        wx.EVT_MENU(self, self.editmask_id, self.on_edit_data) 
    556570 
    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") 
    561574        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, 
    562                                                     self.on_check_item) 
     575                                   self.on_check_item) 
    563576        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU, 
    564577                                   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) 
    569580 
    570581    def on_right_click_theory(self, event): 
     
    588599        Allow Editing Data 
    589600        """ 
    590         #selection = event.GetSelection() 
     601        # selection = event.GetSelection() 
    591602        is_data = True 
    592603        try: 
    593604            id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() 
    594605            data_list, _ = \ 
    595                         self.parent.get_data_manager().get_by_id(id_list=[id]) 
     606                self.parent.get_data_manager().get_by_id(id_list=[id]) 
    596607            if not data_list: 
    597608                is_data = False 
     
    610621        """ 
    611622        # Skipping the save state functionality for release 0.9.0 
    612         #return 
     623        # return 
    613624        pos = event.GetPosition() 
    614625        pos = self.ScreenToClient(pos) 
    615626        self.PopupMenu(self.popUpMenu, pos) 
    616  
    617627 
    618628    def on_check_item(self, event): 
     
    636646        if self.parent is None or \ 
    637647            not hasattr(self.parent, "get_current_perspective") or \ 
    638             len(self.list_of_perspective) == 0: 
     648                        len(self.list_of_perspective) == 0: 
    639649            return 
    640         if self.parent is not None and self.perspective_cbox  is not None: 
     650        if self.parent is not None and self.perspective_cbox is not None: 
    641651            for plug in self.list_of_perspective: 
    642652                if plug.get_perspective(): 
     
    666676                    s_path = str(path) 
    667677                    if state_id not in self.list_cb_data: 
    668                         #new state 
     678                        # new state 
    669679                        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, 
    671682                                        data=(data_id, data_class, state_id)) 
    672683                        data_c.Check(True) 
    673684                        d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
    674685                        d_t_c = self.tree_ctrl.AppendItem(d_i_c, 
    675                                                       'Title: %s' % data_title) 
     686                                                          'Title: %s' % 
     687                                                          data_title) 
    676688                        r_n_c = self.tree_ctrl.AppendItem(d_i_c, 
    677                                                       'Run: %s' % data_run) 
     689                                                          'Run: %s' % data_run) 
    678690                        i_c_c = self.tree_ctrl.AppendItem(d_i_c, 
    679                                                       'Type: %s' % data_class) 
     691                                                          'Type: %s' % 
     692                                                          data_class) 
    680693                        p_c_c = self.tree_ctrl.AppendItem(d_i_c, 
    681                                                       "Path: '%s'" % s_path) 
     694                                                          "Path: '%s'" % s_path) 
    682695                        d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 
    683696 
    684697                        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] + ' [...]' 
    688701                            self.tree_ctrl.AppendItem(d_p_c, process_str) 
    689702                        theory_child = self.tree_ctrl.AppendItem(data_c, 
     
    698711                                                       theory_child] 
    699712                    else: 
    700                         data_ctrl_list =  self.list_cb_data[state_id] 
    701                         #This state is already display replace it contains 
     713                        data_ctrl_list = self.list_cb_data[state_id] 
     714                        # This state is already display replace it contains 
    702715                        data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, _ \ 
    703716                                = data_ctrl_list 
     
    713726                            if not process.is_empty(): 
    714727                                _ = self.tree_ctrl.AppendItem(d_p_c, 
    715                                                               process.single_line_desc()) 
     728                                                    process.single_line_desc()) 
    716729                wx.CallAfter(self.append_theory, state_id, theory_list) 
    717730            # Sort by data name 
    718731            if self.tree_ctrl.root: 
    719732                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() 
    720736        self.enable_remove() 
    721737        self.enable_import() 
     
    756772                                       state_id=state_id, 
    757773                                       theory_list=theory_list) 
    758  
     774        if self.tree_ctrl_theory.GetCount() > 0: 
     775            self.tree_ctrl_theory.root.Expand() 
    759776 
    760777    def append_theory_helper(self, tree, root, state_id, theory_list): 
     
    763780        """ 
    764781        if state_id in self.list_cb_theory.keys(): 
    765             #update current list of theory for this data 
     782            # update current list of theory for this data 
    766783            theory_list_ctrl = self.list_cb_theory[state_id] 
    767784 
     
    777794                    theory_class = theory_data.__class__.__name__ 
    778795                    theory_id = theory_data.id 
    779                     #if theory_state is not None: 
     796                    # if theory_state is not None: 
    780797                    #    name = theory_state.model.name 
    781798                    temp = (theory_id, theory_class, state_id) 
    782799                if theory_id not in theory_list_ctrl: 
    783                     #add new theory 
     800                    # add new theory 
    784801                    t_child = tree.AppendItem(root, 
    785802                                                    name, ct_type=1, data=temp) 
     
    795812                                                   t_p_c] 
    796813                else: 
    797                     #replace theory 
     814                    # replace theory 
    798815                    t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] 
    799816                    tree.SetItemText(t_child, name) 
     
    805822 
    806823        else: 
    807             #data didn't have a theory associated it before 
     824            # data didn't have a theory associated it before 
    808825            theory_list_ctrl = {} 
    809826            for theory_id, item in theory_list.iteritems(): 
     
    813830                    theory_class = theory_data.__class__.__name__ 
    814831                    theory_id = theory_data.id 
    815                     #if theory_state is not None: 
     832                    # if theory_state is not None: 
    816833                    #    name = theory_state.model.name 
    817834                    temp = (theory_id, theory_class, state_id) 
     
    828845 
    829846                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 
    830                 #self.list_cb_theory[data_id] = theory_list_ctrl 
     847                # self.list_cb_theory[data_id] = theory_list_ctrl 
    831848                self.list_cb_theory[state_id] = theory_list_ctrl 
    832  
    833  
    834849 
    835850    def set_data_helper(self): 
     
    889904            wx.PostEvent(self.parent, NewLoadDataEvent()) 
    890905 
    891  
    892     def on_remove(self, event): 
     906    def on_remove(self, event, prompt=True): 
    893907        """ 
    894908        Get a list of item checked and remove them from the treectrl 
    895909        Ask the parent to remove reference to this item 
    896910        """ 
    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 
    902917 
    903918        data_to_remove, theory_to_remove, _ = self.set_data_helper() 
    904919        data_key = [] 
    905920        theory_key = [] 
    906         #remove  data from treectrl 
     921        # remove  data from treectrl 
    907922        for d_key, item in self.list_cb_data.iteritems(): 
    908923            data_c, _, _, _,  _, _, _, _ = item 
     
    915930        # Remove theory from treectrl 
    916931        for _, theory_dict in self.list_cb_theory.iteritems(): 
    917             for  key, value in theory_dict.iteritems(): 
     932            for key, value in theory_dict.iteritems(): 
    918933                item, _, _ = value 
    919934                if item.IsChecked(): 
     
    924939                    theory_key.append(key) 
    925940 
    926         #Remove data and related theory references 
     941        # Remove data and related theory references 
    927942        for key in data_key: 
    928943            del self.list_cb_data[key] 
    929944            if key in theory_key: 
    930945                del self.list_cb_theory[key] 
    931         #remove theory  references independently of data 
     946        # remove theory  references independently of data 
    932947        for key in theory_key: 
    933948            for _, theory_dict in self.list_cb_theory.iteritems(): 
    934949                if key in theory_dict: 
    935                     for  key, value in theory_dict.iteritems(): 
     950                    for key, value in theory_dict.iteritems(): 
    936951                        item, _, _ = value 
    937952                        if item.IsChecked(): 
     
    942957                    del theory_dict[key] 
    943958 
    944  
    945959        self.parent.remove_data(data_id=data_to_remove, 
    946960                                  theory_id=theory_to_remove) 
     
    953967        Get all select data and set them to the current active perspetive 
    954968        """ 
    955         if event != None: 
     969        if event is not None: 
    956970            event.Skip() 
    957971        data_id, theory_id, state_id = self.set_data_helper() 
     
    985999        On close 
    9861000        """ 
    987         if event != None: 
     1001        if event is not None: 
    9881002            event.Skip() 
    9891003        # send parent to update menu with no show nor hide action 
     
    10151029        from the combobox of the current panel 
    10161030        """ 
    1017         #name = event.name 
     1031        # name = event.name 
    10181032        caption = event.caption 
    10191033        if self.cb_plotpanel is not None: 
     
    10331047            if name_plot_panel not in self.cb_plotpanel.GetItems(): 
    10341048                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: 
    10361050                self.cb_plotpanel.SetStringSelection(name_plot_panel) 
    10371051                break 
     
    10591073        On source combobox selection 
    10601074        """ 
    1061         if event != None: 
     1075        if event is not None: 
    10621076            combo = event.GetEventObject() 
    10631077            event.Skip() 
     
    11061120        running "file:///...." 
    11071121 
    1108     :param evt: Triggers on clicking the help button 
     1122    :param event: Triggers on clicking the help button 
    11091123    """ 
    11101124 
     
    11551169        """ 
    11561170        n_t = 0 
    1157         if self.tree_ctrl != None: 
     1171        if self.tree_ctrl is not None: 
    11581172            n_t = self.tree_ctrl.GetCount() 
    11591173        if n_t > 0 and len(self.list_of_perspective) > 0: 
     
    11741188        n_t = 0 
    11751189        n_t_t = 0 
    1176         if self.tree_ctrl != None: 
     1190        if self.tree_ctrl is not None: 
    11771191            n_t = self.tree_ctrl.GetCount() 
    1178         if self.tree_ctrl_theory != None: 
     1192        if self.tree_ctrl_theory is not None: 
    11791193            n_t_t = self.tree_ctrl_theory.GetCount() 
    11801194        if n_t + n_t_t <= 0: 
     
    11901204        n_t = 0 
    11911205        n_t_t = 0 
    1192         if self.tree_ctrl != None: 
     1206        if self.tree_ctrl is not None: 
    11931207            n_t = self.tree_ctrl.GetCount() 
    1194         if self.tree_ctrl_theory != None: 
     1208        if self.tree_ctrl_theory is not None: 
    11951209            n_t_t = self.tree_ctrl_theory.GetCount() 
    11961210        if n_t + n_t_t <= 0: 
     
    12141228        n_t_t = 0 
    12151229        n_l = 0 
    1216         if self.tree_ctrl_theory != None: 
     1230        if self.tree_ctrl_theory is not None: 
    12171231            n_t_t = self.tree_ctrl_theory.GetCount() 
    12181232        n_l = len(self.list_cb_theory) 
     
    12281242        n_t = 0 
    12291243        n_t_t = 0 
    1230         if self.tree_ctrl != None: 
     1244        if self.tree_ctrl is not None: 
    12311245            n_t = self.tree_ctrl.GetCount() 
    1232         if self.tree_ctrl_theory != None: 
     1246        if self.tree_ctrl_theory is not None: 
    12331247            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: 
    12351249            self.selection_cbox.Enable() 
    12361250        else: 
     
    12541268            #self.bt_remove.Hide() 
    12551269            self.bt_add.Hide() 
    1256  
    12571270 
    12581271 
     
    12871300        if not data_list or len(data_list) <= 1: 
    12881301            return 
    1289         #add text 
     1302        # add text 
    12901303 
    12911304        text = "Deleting these file reset some panels.\n" 
     
    12951308        iy = 0 
    12961309        ix = 0 
    1297         #data_count = 0 
     1310        # data_count = 0 
    12981311        for (data_name, in_use, sub_menu) in range(len(data_list)): 
    1299             if in_use == True: 
     1312            if in_use: 
    13001313                ctrl_name = wx.StaticBox(self, -1, str(data_name)) 
    13011314                ctrl_in_use = wx.StaticBox(self, -1, " is used by ") 
    13021315                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) 
    13041317                self.sizer.Add(ctrl_name, (iy, ix), 
    13051318                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    13121325            iy += 1 
    13131326        self._panel.SetSizer(self.sizer) 
    1314         #add sizer 
     1327        # add sizer 
    13151328        self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    13161329        button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 
     
    13751388 
    13761389 
    1377  
    13781390from sas.sasgui.guiframe.dataFitting import Theory1D 
    13791391from sas.sasgui.guiframe.data_state import DataState 
     1392 
    13801393 
    13811394class State(): 
     
    13911404        return self.msg 
    13921405 
     1406 
    13931407def set_data_state(data=None, path=None, theory=None, state=None): 
    13941408    """ 
     
    14051419    app = wx.App() 
    14061420    try: 
    1407         #list_of_perspective = [('perspective2', False), ('perspective1', True)] 
     1421        # list_of_perspective = [('perspective2', False), ('perspective1', True)] 
    14081422        data_list1 = {} 
    14091423        # state 1 
     
    14201434        state1 = State() 
    14211435        data_list1['1'] = set_data_state(data1, path1, theory1, state1) 
    1422         #state 2 
     1436        # state 2 
    14231437        data1 = Data2D() 
    14241438        data1.name = "data2" 
     
    14281442        theory1.name = "CoreShell 07/24/25" 
    14291443        path1 = "path2" 
    1430         #state3 
     1444        # state3 
    14311445        state1 = State() 
    14321446        data_list1['2'] = set_data_state(data1, path1, theory1, state1) 
     
    14451459        process1.data = "07/22/2010" 
    14461460        data_list1['4'] = set_data_state(data1, path1, theory1, state1) 
    1447         #state 4 
     1461        # state 4 
    14481462        temp_data_list = {} 
    14491463        data1.name = "data5 erasing data2" 
    14501464        temp_data_list['4'] = set_data_state(data1, path1, theory1, state1) 
    1451         #state 5 
     1465        # state 5 
    14521466        data1 = Data2D() 
    14531467        data1.name = "data3" 
     
    14821496        window.load_data_list(list=temp_data_list) 
    14831497    except: 
    1484         #raise 
     1498        # raise 
    14851499        print "error", sys.exc_value 
    14861500 
Note: See TracChangeset for help on using the changeset viewer.