Ignore:
Timestamp:
Oct 20, 2016 3:54:06 PM (8 years ago)
Author:
krzywon
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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
880e845, cf1910f
Parents:
8b645cc
Message:

Fixes #738: No errors are thrown on loading projects with fits, plus linting.

File:
1 edited

Legend:

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

    r998ca90 rc8e1996  
    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 | CT.TR_HIDE_ROOT |\ 
     69                    wx.WANTS_CHARS | CT.TR_HAS_VARIABLE_ROW_HEIGHT 
    6970 
    7071 
     
    7475    """ 
    7576    def __init__(self, parent, *args, **kwds): 
    76         #agwstyle is introduced in wx.2.8.11 but is not working for mac 
     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: 
     
    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) 
     
    523525        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_CHECKING, self.on_check_item) 
    524526        self.tree_ctrl.Bind(CT.EVT_TREE_ITEM_MENU, self.on_right_click_data) 
    525         ## Create context menu for page 
     527        # Create context menu for page 
    526528        self.data_menu = wx.Menu() 
    527529        id = wx.NewId() 
     
    558560        tree_ctrl_theory_label.SetForegroundColour('blue') 
    559561        self.tree_ctrl_theory = DataTreeCtrl(parent=self, 
    560                                                     style=wx.SUNKEN_BORDER) 
     562                                             style=wx.SUNKEN_BORDER) 
    561563        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_CHECKING, 
    562                                                     self.on_check_item) 
     564                                   self.on_check_item) 
    563565        self.tree_ctrl_theory.Bind(CT.EVT_TREE_ITEM_MENU, 
    564566                                   self.on_right_click_theory) 
    565567        self.sizer1.Add(tree_ctrl_label, 0, wx.LEFT, 10) 
    566         self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND|wx.ALL, 10) 
     568        self.sizer1.Add(self.tree_ctrl, 1, wx.EXPAND | wx.ALL, 10) 
    567569        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) 
     570        self.sizer1.Add(self.tree_ctrl_theory, 1, wx.EXPAND | wx.ALL, 10) 
    569571 
    570572    def on_right_click_theory(self, event): 
     
    588590        Allow Editing Data 
    589591        """ 
    590         #selection = event.GetSelection() 
     592        # selection = event.GetSelection() 
    591593        is_data = True 
    592594        try: 
    593595            id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() 
    594596            data_list, _ = \ 
    595                         self.parent.get_data_manager().get_by_id(id_list=[id]) 
     597                self.parent.get_data_manager().get_by_id(id_list=[id]) 
    596598            if not data_list: 
    597599                is_data = False 
     
    610612        """ 
    611613        # Skipping the save state functionality for release 0.9.0 
    612         #return 
     614        # return 
    613615        pos = event.GetPosition() 
    614616        pos = self.ScreenToClient(pos) 
    615617        self.PopupMenu(self.popUpMenu, pos) 
    616  
    617618 
    618619    def on_check_item(self, event): 
     
    636637        if self.parent is None or \ 
    637638            not hasattr(self.parent, "get_current_perspective") or \ 
    638             len(self.list_of_perspective) == 0: 
     639                        len(self.list_of_perspective) == 0: 
    639640            return 
    640         if self.parent is not None and self.perspective_cbox  is not None: 
     641        if self.parent is not None and self.perspective_cbox is not None: 
    641642            for plug in self.list_of_perspective: 
    642643                if plug.get_perspective(): 
     
    666667                    s_path = str(path) 
    667668                    if state_id not in self.list_cb_data: 
    668                         #new state 
     669                        # new state 
    669670                        data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, 
    670                                         0, data_name, ct_type=1, 
     671                                                           0, data_name, 
     672                                                           ct_type=1, 
    671673                                        data=(data_id, data_class, state_id)) 
    672674                        data_c.Check(True) 
    673675                        d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
    674676                        d_t_c = self.tree_ctrl.AppendItem(d_i_c, 
    675                                                       'Title: %s' % data_title) 
     677                                                          'Title: %s' % 
     678                                                          data_title) 
    676679                        r_n_c = self.tree_ctrl.AppendItem(d_i_c, 
    677                                                       'Run: %s' % data_run) 
     680                                                          'Run: %s' % data_run) 
    678681                        i_c_c = self.tree_ctrl.AppendItem(d_i_c, 
    679                                                       'Type: %s' % data_class) 
     682                                                          'Type: %s' % 
     683                                                          data_class) 
    680684                        p_c_c = self.tree_ctrl.AppendItem(d_i_c, 
    681                                                       "Path: '%s'" % s_path) 
     685                                                          "Path: '%s'" % s_path) 
    682686                        d_p_c = self.tree_ctrl.AppendItem(d_i_c, 'Process') 
    683687 
    684688                        for process in process_list: 
    685                             process_str = str(process).replace('\n',' ') 
    686                             if len(process_str)>20: 
    687                                 process_str = process_str[:20]+' [...]' 
     689                            process_str = str(process).replace('\n', ' ') 
     690                            if len(process_str) > 20: 
     691                                process_str = process_str[:20] + ' [...]' 
    688692                            self.tree_ctrl.AppendItem(d_p_c, process_str) 
    689693                        theory_child = self.tree_ctrl.AppendItem(data_c, 
     
    698702                                                       theory_child] 
    699703                    else: 
    700                         data_ctrl_list =  self.list_cb_data[state_id] 
    701                         #This state is already display replace it contains 
     704                        data_ctrl_list = self.list_cb_data[state_id] 
     705                        # This state is already display replace it contains 
    702706                        data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, _ \ 
    703707                                = data_ctrl_list 
     
    713717                            if not process.is_empty(): 
    714718                                _ = self.tree_ctrl.AppendItem(d_p_c, 
    715                                                               process.single_line_desc()) 
     719                                                    process.single_line_desc()) 
    716720                wx.CallAfter(self.append_theory, state_id, theory_list) 
    717721            # Sort by data name 
     
    757761                                       theory_list=theory_list) 
    758762 
    759  
    760763    def append_theory_helper(self, tree, root, state_id, theory_list): 
    761764        """ 
     
    763766        """ 
    764767        if state_id in self.list_cb_theory.keys(): 
    765             #update current list of theory for this data 
     768            # update current list of theory for this data 
    766769            theory_list_ctrl = self.list_cb_theory[state_id] 
    767770 
     
    777780                    theory_class = theory_data.__class__.__name__ 
    778781                    theory_id = theory_data.id 
    779                     #if theory_state is not None: 
     782                    # if theory_state is not None: 
    780783                    #    name = theory_state.model.name 
    781784                    temp = (theory_id, theory_class, state_id) 
    782785                if theory_id not in theory_list_ctrl: 
    783                     #add new theory 
     786                    # add new theory 
    784787                    t_child = tree.AppendItem(root, 
    785788                                                    name, ct_type=1, data=temp) 
     
    795798                                                   t_p_c] 
    796799                else: 
    797                     #replace theory 
     800                    # replace theory 
    798801                    t_child, i_c_c, t_p_c = theory_list_ctrl[theory_id] 
    799802                    tree.SetItemText(t_child, name) 
     
    805808 
    806809        else: 
    807             #data didn't have a theory associated it before 
     810            # data didn't have a theory associated it before 
    808811            theory_list_ctrl = {} 
    809812            for theory_id, item in theory_list.iteritems(): 
     
    813816                    theory_class = theory_data.__class__.__name__ 
    814817                    theory_id = theory_data.id 
    815                     #if theory_state is not None: 
     818                    # if theory_state is not None: 
    816819                    #    name = theory_state.model.name 
    817820                    temp = (theory_id, theory_class, state_id) 
     
    828831 
    829832                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 
    830                 #self.list_cb_theory[data_id] = theory_list_ctrl 
     833                # self.list_cb_theory[data_id] = theory_list_ctrl 
    831834                self.list_cb_theory[state_id] = theory_list_ctrl 
    832  
    833  
    834835 
    835836    def set_data_helper(self): 
     
    889890            wx.PostEvent(self.parent, NewLoadDataEvent()) 
    890891 
    891  
    892     def on_remove(self, event, msg=""): 
     892    def on_remove(self, event, prompt=True): 
    893893        """ 
    894894        Get a list of item checked and remove them from the treectrl 
    895895        Ask the parent to remove reference to this item 
    896896        """ 
    897         if msg == "": 
     897        if prompt: 
    898898            msg = "This operation will delete the data sets checked " 
    899899            msg += "and all the dependents." 
    900         msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) 
    901         if msg_box.ShowModal() != wx.ID_OK: 
    902             return True 
     900            msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK|wx.CANCEL) 
     901            if msg_box.ShowModal() != wx.ID_OK: 
     902                return 
    903903 
    904904        data_to_remove, theory_to_remove, _ = self.set_data_helper() 
    905905        data_key = [] 
    906906        theory_key = [] 
    907         #remove  data from treectrl 
     907        # remove  data from treectrl 
    908908        for d_key, item in self.list_cb_data.iteritems(): 
    909909            data_c, _, _, _,  _, _, _, _ = item 
     
    916916        # Remove theory from treectrl 
    917917        for _, theory_dict in self.list_cb_theory.iteritems(): 
    918             for  key, value in theory_dict.iteritems(): 
     918            for key, value in theory_dict.iteritems(): 
    919919                item, _, _ = value 
    920920                if item.IsChecked(): 
     
    925925                    theory_key.append(key) 
    926926 
    927         #Remove data and related theory references 
     927        # Remove data and related theory references 
    928928        for key in data_key: 
    929929            del self.list_cb_data[key] 
    930930            if key in theory_key: 
    931931                del self.list_cb_theory[key] 
    932         #remove theory  references independently of data 
     932        # remove theory  references independently of data 
    933933        for key in theory_key: 
    934934            for _, theory_dict in self.list_cb_theory.iteritems(): 
    935935                if key in theory_dict: 
    936                     for  key, value in theory_dict.iteritems(): 
     936                    for key, value in theory_dict.iteritems(): 
    937937                        item, _, _ = value 
    938938                        if item.IsChecked(): 
     
    943943                    del theory_dict[key] 
    944944 
    945  
    946945        self.parent.remove_data(data_id=data_to_remove, 
    947946                                  theory_id=theory_to_remove) 
     
    954953        Get all select data and set them to the current active perspetive 
    955954        """ 
    956         if event != None: 
     955        if event is not None: 
    957956            event.Skip() 
    958957        data_id, theory_id, state_id = self.set_data_helper() 
     
    986985        On close 
    987986        """ 
    988         if event != None: 
     987        if event is not None: 
    989988            event.Skip() 
    990989        # send parent to update menu with no show nor hide action 
     
    10161015        from the combobox of the current panel 
    10171016        """ 
    1018         #name = event.name 
     1017        # name = event.name 
    10191018        caption = event.caption 
    10201019        if self.cb_plotpanel is not None: 
     
    10341033            if name_plot_panel not in self.cb_plotpanel.GetItems(): 
    10351034                self.cb_plotpanel.Append(name_plot_panel, value) 
    1036             if name != None and name == name_plot_panel: 
     1035            if name is not None and name == name_plot_panel: 
    10371036                self.cb_plotpanel.SetStringSelection(name_plot_panel) 
    10381037                break 
     
    10601059        On source combobox selection 
    10611060        """ 
    1062         if event != None: 
     1061        if event is not None: 
    10631062            combo = event.GetEventObject() 
    10641063            event.Skip() 
     
    11071106        running "file:///...." 
    11081107 
    1109     :param evt: Triggers on clicking the help button 
     1108    :param event: Triggers on clicking the help button 
    11101109    """ 
    11111110 
     
    11561155        """ 
    11571156        n_t = 0 
    1158         if self.tree_ctrl != None: 
     1157        if self.tree_ctrl is not None: 
    11591158            n_t = self.tree_ctrl.GetCount() 
    11601159        if n_t > 0 and len(self.list_of_perspective) > 0: 
     
    11751174        n_t = 0 
    11761175        n_t_t = 0 
    1177         if self.tree_ctrl != None: 
     1176        if self.tree_ctrl is not None: 
    11781177            n_t = self.tree_ctrl.GetCount() 
    1179         if self.tree_ctrl_theory != None: 
     1178        if self.tree_ctrl_theory is not None: 
    11801179            n_t_t = self.tree_ctrl_theory.GetCount() 
    11811180        if n_t + n_t_t <= 0: 
     
    11911190        n_t = 0 
    11921191        n_t_t = 0 
    1193         if self.tree_ctrl != None: 
     1192        if self.tree_ctrl is not None: 
    11941193            n_t = self.tree_ctrl.GetCount() 
    1195         if self.tree_ctrl_theory != None: 
     1194        if self.tree_ctrl_theory is not None: 
    11961195            n_t_t = self.tree_ctrl_theory.GetCount() 
    11971196        if n_t + n_t_t <= 0: 
     
    12151214        n_t_t = 0 
    12161215        n_l = 0 
    1217         if self.tree_ctrl_theory != None: 
     1216        if self.tree_ctrl_theory is not None: 
    12181217            n_t_t = self.tree_ctrl_theory.GetCount() 
    12191218        n_l = len(self.list_cb_theory) 
     
    12291228        n_t = 0 
    12301229        n_t_t = 0 
    1231         if self.tree_ctrl != None: 
     1230        if self.tree_ctrl is not None: 
    12321231            n_t = self.tree_ctrl.GetCount() 
    1233         if self.tree_ctrl_theory != None: 
     1232        if self.tree_ctrl_theory is not None: 
    12341233            n_t_t = self.tree_ctrl_theory.GetCount() 
    1235         if n_t + n_t_t > 0 and self.selection_cbox != None: 
     1234        if n_t + n_t_t > 0 and self.selection_cbox is not None: 
    12361235            self.selection_cbox.Enable() 
    12371236        else: 
     
    12551254            #self.bt_remove.Hide() 
    12561255            self.bt_add.Hide() 
    1257  
    12581256 
    12591257 
     
    12881286        if not data_list or len(data_list) <= 1: 
    12891287            return 
    1290         #add text 
     1288        # add text 
    12911289 
    12921290        text = "Deleting these file reset some panels.\n" 
     
    12961294        iy = 0 
    12971295        ix = 0 
    1298         #data_count = 0 
     1296        # data_count = 0 
    12991297        for (data_name, in_use, sub_menu) in range(len(data_list)): 
    1300             if in_use == True: 
     1298            if in_use: 
    13011299                ctrl_name = wx.StaticBox(self, -1, str(data_name)) 
    13021300                ctrl_in_use = wx.StaticBox(self, -1, " is used by ") 
    13031301                plug_name = str(sub_menu) + "\n" 
    1304                 #ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 
     1302                # ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 
    13051303                self.sizer.Add(ctrl_name, (iy, ix), 
    13061304                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    13131311            iy += 1 
    13141312        self._panel.SetSizer(self.sizer) 
    1315         #add sizer 
     1313        # add sizer 
    13161314        self._sizer_button.Add((20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE, 0) 
    13171315        button_cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 
     
    13761374 
    13771375 
    1378  
    13791376from sas.sasgui.guiframe.dataFitting import Theory1D 
    13801377from sas.sasgui.guiframe.data_state import DataState 
     1378 
    13811379 
    13821380class State(): 
     
    13921390        return self.msg 
    13931391 
     1392 
    13941393def set_data_state(data=None, path=None, theory=None, state=None): 
    13951394    """ 
     
    14061405    app = wx.App() 
    14071406    try: 
    1408         #list_of_perspective = [('perspective2', False), ('perspective1', True)] 
     1407        # list_of_perspective = [('perspective2', False), ('perspective1', True)] 
    14091408        data_list1 = {} 
    14101409        # state 1 
     
    14211420        state1 = State() 
    14221421        data_list1['1'] = set_data_state(data1, path1, theory1, state1) 
    1423         #state 2 
     1422        # state 2 
    14241423        data1 = Data2D() 
    14251424        data1.name = "data2" 
     
    14291428        theory1.name = "CoreShell 07/24/25" 
    14301429        path1 = "path2" 
    1431         #state3 
     1430        # state3 
    14321431        state1 = State() 
    14331432        data_list1['2'] = set_data_state(data1, path1, theory1, state1) 
     
    14461445        process1.data = "07/22/2010" 
    14471446        data_list1['4'] = set_data_state(data1, path1, theory1, state1) 
    1448         #state 4 
     1447        # state 4 
    14491448        temp_data_list = {} 
    14501449        data1.name = "data5 erasing data2" 
    14511450        temp_data_list['4'] = set_data_state(data1, path1, theory1, state1) 
    1452         #state 5 
     1451        # state 5 
    14531452        data1 = Data2D() 
    14541453        data1.name = "data3" 
     
    14831482        window.load_data_list(list=temp_data_list) 
    14841483    except: 
    1485         #raise 
     1484        # raise 
    14861485        print "error", sys.exc_value 
    14871486 
Note: See TracChangeset for help on using the changeset viewer.