Changeset 5e5704d in sasview


Ignore:
Timestamp:
Jul 12, 2012 11:55:30 AM (12 years ago)
Author:
Jae Cho <jhjcho@…>
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:
d4d4c8a
Parents:
67fb83b
Message:

data panel: clean up for pylint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansguiframe/src/sans/guiframe/data_panel.py

    r38226d26 r5e5704d  
    156156        self.data_menu = None 
    157157        self.popUpMenu = None 
    158         
     158        self.plot3d_id = None 
     159        self.editmask_id = None 
     160        # Default attr 
     161        self.vbox  = None 
     162        self.sizer1 = None 
     163        self.sizer2 = None 
     164        self.sizer3 = None 
     165        self.sizer4 = None 
     166        self.sizer5 = None 
     167        self.selection_cbox = None 
     168        self.bt_add = None 
     169        self.bt_remove = None 
     170        self.bt_import = None 
     171        self.bt_append_plot = None 
     172        self.bt_plot = None 
     173        self.bt_freeze = None 
     174        self.cb_plotpanel = None 
     175        self.rb_single_mode = None 
     176        self.rb_batch_mode = None 
     177 
    159178        self.owner = None 
    160179        self.do_layout() 
     
    176195    def disable_app_combo(self, enable): 
    177196        """ 
     197        Disable app combo box 
    178198        """ 
    179199        self.perspective_cbox.Enable(enable) 
     
    217237            self.selection_cbox.Append(str(option)) 
    218238        self.selection_cbox.SetValue('Select all Data') 
    219         wx.EVT_COMBOBOX(self.selection_cbox,-1, self._on_selection_type) 
    220         self.sizer5.AddMany([(select_txt,0, wx.ALL,5), 
     239        wx.EVT_COMBOBOX(self.selection_cbox, -1, self._on_selection_type) 
     240        self.sizer5.AddMany([(select_txt, 0, wx.ALL,5),  
    221241                            (self.selection_cbox,0, wx.ALL,5)]) 
    222242        self.enable_selection() 
     
    235255        option = self.selection_cbox.GetString(pos) 
    236256        for item in self.list_cb_data.values(): 
    237             data_ctrl, _, _, _, _, _, _, _= item 
    238             data_id, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl)  
     257            data_ctrl, _, _, _, _, _, _, _ = item 
     258            _, data_class, _ = self.tree_ctrl.GetItemPyData(data_ctrl)  
    239259            if option == 'Select all Data': 
    240260                self.tree_ctrl.CheckItem(data_ctrl, True)  
     
    266286        Layout widgets related to buttons 
    267287        """ 
    268         w, _ = self.GetSize() 
    269         
    270288        self.bt_add = wx.Button(self, wx.NewId(), "Load Data",  
    271289                                size=(BUTTON_WIDTH, -1)) 
     
    278296        self.bt_import = wx.Button(self, wx.NewId(), "Send To", 
    279297                                    size=(BUTTON_WIDTH, -1)) 
    280         self.bt_import.SetToolTipString("Send set of Data to active perspective") 
     298        self.bt_import.SetToolTipString("Send Data set to active perspective") 
    281299        wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_import) 
    282300        self.perspective_cbox = wx.ComboBox(self, -1, 
     
    289307        self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To", 
    290308                                        size=(BUTTON_WIDTH, -1)) 
    291         self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") 
     309        self.bt_append_plot.SetToolTipString( \ 
     310                                "Plot the selected data in the active panel") 
    292311        wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 
    293312         
     
    311330            self.cb_plotpanel = wx.ComboBox(self, -1,  
    312331                                            style=wx.CB_READONLY|wx.CB_SORT) 
    313         wx.EVT_COMBOBOX(self.cb_plotpanel,-1, self._on_plot_selection) 
     332        wx.EVT_COMBOBOX(self.cb_plotpanel, -1, self._on_plot_selection) 
    314333        self.cb_plotpanel.Disable() 
    315334 
     
    323342                             ((10, 10)), 
    324343                             (self.bt_append_plot), 
    325                              (self.cb_plotpanel, wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
     344                             (self.cb_plotpanel,  
     345                              wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
    326346                             ((5, 5)), 
    327347                             ((5, 5)), 
    328348                             (self.bt_import, 0, wx.EXPAND|wx.RIGHT, 5), 
    329                              (self.perspective_cbox, wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
     349                             (self.perspective_cbox,  
     350                              wx.EXPAND|wx.ADJUST_MINSIZE, 5), 
    330351                             ((10, 10)), 
    331352                             (self.sizer4), 
     
    365386        """ 
    366387        if self.parent is not None: 
    367                 wx.PostEvent(self.parent,  
    368                              NewBatchEvent(enable=False)) 
     388            wx.PostEvent(self.parent, NewBatchEvent(enable=False)) 
    369389        
    370390    def on_batch_mode(self, event): 
     
    386406        id, _, _ = self.FindFocus().GetSelection().GetData() 
    387407        data_list, theory_list = \ 
    388                             self.parent._data_manager.get_by_id(id_list=[id]) 
     408                        self.parent.get_data_manager().get_by_id(id_list=[id]) 
    389409        if data_list: 
    390410            data = data_list.values()[0] 
     
    483503        wx.EVT_MENU(self, id, self.on_save_as) 
    484504     
    485         self.quickplot_id = wx.NewId() 
     505        quickplot_id = wx.NewId() 
    486506        name = "Quick Plot" 
    487507        msg = "Plot the current Data" 
    488         self.data_menu.Append(self.quickplot_id, name, msg) 
    489         wx.EVT_MENU(self, self.quickplot_id, self.on_quick_plot) 
     508        self.data_menu.Append(quickplot_id, name, msg) 
     509        wx.EVT_MENU(self, quickplot_id, self.on_quick_plot) 
    490510         
    491511        self.plot3d_id = wx.NewId() 
     
    522542                            self.tree_ctrl_theory.GetSelection().GetData() 
    523543            data_list, _ = \ 
    524                             self.parent._data_manager.get_by_id(id_list=[id]) 
     544                            self.parent.get_data_manager().get_by_id(id_list=[id]) 
    525545        except: 
    526546            return 
     
    535555        Allow Editing Data 
    536556        """ 
    537         selection = event.GetSelection() 
     557        #selection = event.GetSelection() 
    538558        is_data = True 
    539559        try: 
    540560            id, data_class_name, _ = self.tree_ctrl.GetSelection().GetData() 
    541561            data_list, _ = \ 
    542                             self.parent._data_manager.get_by_id(id_list=[id]) 
     562                            self.parent.get_data_manager().get_by_id(id_list=[id]) 
    543563            if not data_list: 
    544564                is_data = False 
     
    565585    def on_check_item(self, event): 
    566586        """ 
     587        On check item 
    567588        """ 
    568589        item = event.GetItem() 
     
    613634                    if state_id not in self.list_cb_data: 
    614635                        #new state 
    615                         data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root,0, 
    616                                                           data_name, ct_type=1,  
    617                                              data=(data_id, data_class, state_id)) 
     636                        data_c = self.tree_ctrl.InsertItem(self.tree_ctrl.root, 
     637                                        0, data_name, ct_type=1,  
     638                                        data=(data_id, data_class, state_id)) 
    618639                        data_c.Check(True) 
    619640                        d_i_c = self.tree_ctrl.AppendItem(data_c, 'Info') 
     
    632653                            if len(process_str)>20: 
    633654                                process_str = process_str[:20]+' [...]' 
    634                             i_t_c = self.tree_ctrl.AppendItem(d_p_c, 
    635                                                               process_str) 
    636                         theory_child = self.tree_ctrl.AppendItem(data_c, "THEORIES") 
    637                         
     655                            self.tree_ctrl.AppendItem(d_p_c, process_str) 
     656                        theory_child = self.tree_ctrl.AppendItem(data_c,  
     657                                                                 "THEORIES") 
    638658                        self.list_cb_data[state_id] = [data_c,  
    639659                                                       d_i_c, 
     
    641661                                                       r_n_c, 
    642662                                                       i_c_c, 
    643                                                         p_c_c, 
    644                                                          d_p_c, 
    645                                                          theory_child] 
     663                                                       p_c_c, 
     664                                                       d_p_c, 
     665                                                       theory_child] 
    646666                    else: 
    647667                        data_ctrl_list =  self.list_cb_data[state_id] 
    648668                        #This state is already display replace it contains 
    649                         data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c = data_ctrl_list 
     669                        data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c \ 
     670                                = data_ctrl_list 
    650671                        self.tree_ctrl.SetItemText(data_c, data_name)  
    651672                        temp = (data_id, data_class, state_id) 
    652673                        self.tree_ctrl.SetItemPyData(data_c, temp)  
    653                         self.tree_ctrl.SetItemText(i_c_c, 'Type: %s' % data_class) 
    654                         self.tree_ctrl.SetItemText(p_c_c, 'Path: %s' % s_path)  
     674                        self.tree_ctrl.SetItemText(i_c_c,  
     675                                                   'Type: %s' % data_class) 
     676                        self.tree_ctrl.SetItemText(p_c_c,  
     677                                                   'Path: %s' % s_path)  
    655678                        self.tree_ctrl.DeleteChildren(d_p_c)  
    656679                        for process in process_list: 
     
    672695        """ 
    673696        for item in self.list_cb_data.values(): 
    674             data_ctrl, _, _, _, _, _,_, _ = item 
     697            data_ctrl, _, _, _, _, _, _, _ = item 
    675698            self.tree_ctrl.CheckItem(data_ctrl, False)  
    676699        self.enable_append() 
     
    696719            tree = self.tree_ctrl 
    697720        if root is not None: 
    698              wx.CallAfter(self.append_theory_helper, tree=tree, root=root,  
     721            wx.CallAfter(self.append_theory_helper, tree=tree, root=root,  
    699722                                       state_id=state_id,  
    700723                                       theory_list=theory_list) 
     
    703726    def append_theory_helper(self, tree, root, state_id, theory_list): 
    704727        """ 
     728        Append theory helper 
    705729        """ 
    706730        if state_id in self.list_cb_theory.keys(): 
     
    709733 
    710734            for theory_id, item in theory_list.iteritems(): 
    711                 theory_data, theory_state = item 
     735                theory_data, _ = item 
    712736                if theory_data is None: 
    713737                    name = "Unknown" 
     
    732756                     
    733757                    for process in theory_data.process: 
    734                         i_t_c = tree.AppendItem(t_p_c, 
    735                                                           process.__str__()) 
     758                        tree.AppendItem(t_p_c, process.__str__()) 
    736759                    theory_list_ctrl[theory_id] = [t_child,  
    737760                                                   i_c_c,  
     
    745768                    tree.DeleteChildren(t_p_c)  
    746769                    for process in theory_data.process: 
    747                         i_t_c = tree.AppendItem(t_p_c, 
    748                                                           process.__str__()) 
     770                        tree.AppendItem(t_p_c, process.__str__()) 
    749771               
    750772        else: 
     
    769791                     
    770792                    for process in theory_data.process: 
    771                         i_t_c = tree.AppendItem(t_p_c, 
    772                                                           process.__str__()) 
     793                        tree.AppendItem(t_p_c, process.__str__()) 
    773794             
    774795                    theory_list_ctrl[theory_id] = [t_child, i_c_c, t_p_c] 
     
    780801    def set_data_helper(self): 
    781802        """ 
     803        Set data helper 
    782804        """ 
    783805        data_to_plot = [] 
     
    793815            
    794816        for theory_dict in self.list_cb_theory.values(): 
    795             for key, value in theory_dict.iteritems(): 
     817            for _, value in theory_dict.iteritems(): 
    796818                item, _, _ = value 
    797819                if item.IsChecked(): 
     
    804826    def remove_by_id(self, id): 
    805827        """ 
     828        Remove_dat by id 
    806829        """ 
    807830        for item in self.list_cb_data.values(): 
    808             data_c, _, _, _, _, _,  _, theory_child = item 
     831            data_c, _, _, _, _, _,  _, _ = item 
    809832            data_id, _, state_id = self.tree_ctrl.GetItemPyData(data_c)  
    810833            if id == data_id: 
     
    820843        """ 
    821844        if error is not None or str(error).strip() != "": 
    822             dial = wx.MessageDialog(self.parent, str(error), 'Error Loading File', 
    823                                 wx.OK | wx.ICON_EXCLAMATION) 
     845            dial = wx.MessageDialog(self.parent, str(error),  
     846                                    'Error Loading File', 
     847                                    wx.OK | wx.ICON_EXCLAMATION) 
    824848            dial.ShowModal()   
    825849         
     
    848872        #remove  data from treectrl 
    849873        for d_key, item in self.list_cb_data.iteritems(): 
    850             data_c, d_i_c, d_t_c, r_n_c,  i_c_c, p_c_c, d_p_c, t_c = item 
     874            data_c, _, _, _,  _, _, _, _ = item 
    851875            if data_c.IsChecked(): 
    852876                self.tree_ctrl.Delete(data_c) 
     
    856880                    theory_to_remove += theory_list_ctrl.keys() 
    857881        # Remove theory from treectrl        
    858         for t_key, theory_dict in self.list_cb_theory.iteritems(): 
     882        for _, theory_dict in self.list_cb_theory.iteritems(): 
    859883            for  key, value in theory_dict.iteritems(): 
    860884                item, _, _ = value 
     
    957981        from the combobox of the current panel 
    958982        """ 
    959         name = event.name 
     983        #name = event.name 
    960984        caption = event.caption 
    961985        if self.cb_plotpanel is not None: 
     
    969993        set the plot panel on focus 
    970994        """ 
    971         for key, value in self.parent.plot_panels.iteritems(): 
     995        for _, value in self.parent.plot_panels.iteritems(): 
    972996            name_plot_panel = str(value.window_caption) 
    973997            if name_plot_panel not in self.cb_plotpanel.GetItems(): 
     
    10871111            self.cb_plotpanel.Disable() 
    10881112        elif self.cb_plotpanel.GetCount() <= 0: 
    1089                 self.cb_plotpanel.Disable() 
    1090                 self.bt_append_plot.Disable() 
     1113            self.cb_plotpanel.Disable() 
     1114            self.bt_append_plot.Disable() 
    10911115        else: 
    10921116            self.bt_append_plot.Enable() 
     
    11831207        iy = 0 
    11841208        ix = 0 
    1185         data_count = 0 
     1209        #data_count = 0 
    11861210        for (data_name, in_use, sub_menu) in range(len(data_list)): 
    11871211            if in_use == True: 
     
    11891213                ctrl_in_use = wx.StaticBox(self, -1, " is used by ") 
    11901214                plug_name = str(sub_menu) + "\n" 
    1191                 ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 
     1215                #ctrl_sub_menu = wx.StaticBox(self, -1, plug_name) 
    11921216                self.sizer.Add(ctrl_name, (iy, ix), 
    11931217                           (1, 1), wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) 
     
    12321256             
    12331257class DataFrame(wx.Frame): 
     1258    """ 
     1259    Data Frame 
     1260    """ 
    12341261    ## Internal name for the AUI manager 
    12351262    window_name = "Data Panel" 
     
    12401267    ALWAYS_ON = True 
    12411268     
    1242     def __init__(self, parent=None, owner=None, manager=None,size=(300, 800), 
    1243                          list_of_perspective=[],list=[], *args, **kwds): 
     1269    def __init__(self, parent=None, owner=None, manager=None, size=(300, 800), 
     1270                         list_of_perspective=[], list=[], *args, **kwds): 
    12441271        kwds['size'] = size 
    12451272        kwds['id'] = -1 
    1246         kwds['title']= "Loaded Data" 
     1273        kwds['title'] = "Loaded Data" 
    12471274        wx.Frame.__init__(self, parent=parent, *args, **kwds) 
    12481275        self.parent = parent 
     
    12611288    
    12621289     
    1263 from dataFitting import Data1D 
    1264 from dataFitting import Data2D, Theory1D 
    1265 from data_state import DataState 
    1266 import sys 
     1290from sans.guiframe.dataFitting import Data1D 
     1291from sans.guiframe.dataFitting import Data2D, Theory1D 
     1292from sans.guiframe.data_state import DataState 
     1293 
    12671294class State(): 
     1295    """ 
     1296    DataPanel State 
     1297    """ 
    12681298    def __init__(self): 
    12691299        self.msg = "" 
     
    12751305     
    12761306def set_data_state(data=None, path=None, theory=None, state=None): 
     1307    """ 
     1308    Set data state 
     1309    """ 
    12771310    dstate = DataState(data=data) 
    12781311    dstate.set_path(path=path) 
     
    12801313   
    12811314    return dstate 
    1282 """' 
    1283 data_list = [1:('Data1', 'Data1D', '07/01/2010', "theory1d", "state1"),  
    1284             ('Data2', 'Data2D', '07/03/2011', "theory2d", "state1"),  
    1285             ('Data3', 'Theory1D', '06/01/2010', "theory1d", "state1"),  
    1286             ('Data4', 'Theory2D', '07/01/2010', "theory2d", "state1"),  
    1287             ('Data5', 'Theory2D', '07/02/2010', "theory2d", "state1")]  
    1288 """       
     1315     
    12891316if __name__ == "__main__": 
    12901317     
    12911318    app = wx.App() 
    12921319    try: 
    1293         list_of_perspective = [('perspective2', False), ('perspective1', True)] 
    1294         data_list = {} 
     1320        #list_of_perspective = [('perspective2', False), ('perspective1', True)] 
     1321        data_list1 = {} 
    12951322        # state 1 
    1296         data = Data2D() 
    1297         data.name = "data2" 
    1298         data.id = 1 
    1299         data.append_empty_process() 
    1300         process = data.process[len(data.process)-1] 
    1301         process.data = "07/01/2010" 
     1323        data1 = Data2D() 
     1324        data1.name = "data2" 
     1325        data1.id = 1 
     1326        data1.append_empty_process() 
     1327        process1 = data1.process[len(data1.process)-1] 
     1328        process1.data = "07/01/2010" 
    13021329        theory = Data2D() 
    13031330        theory.id = 34 
    13041331        theory.name = "theory1" 
    13051332        path = "path1" 
    1306         state = State() 
    1307         data_list['1']=set_data_state(data, path,theory, state) 
     1333        state1 = State() 
     1334        data_list1['1'] = set_data_state(data1, path,theory, state1) 
    13081335        #state 2 
    1309         data = Data2D() 
    1310         data.name = "data2" 
    1311         data.id = 76 
     1336        data1 = Data2D() 
     1337        data1.name = "data2" 
     1338        data1.id = 76 
    13121339        theory = Data2D() 
    13131340        theory.id = 78 
     
    13151342        path = "path2" 
    13161343        #state3 
    1317         state = State() 
    1318         data_list['2']=set_data_state(data, path,theory, state) 
    1319         data = Data1D() 
    1320         data.id = 3 
    1321         data.name = "data2" 
     1344        state1 = State() 
     1345        data_list1['2'] = set_data_state(data1, path,theory, state1) 
     1346        data1 = Data1D() 
     1347        data1.id = 3 
     1348        data1.name = "data2" 
    13221349        theory = Theory1D() 
    13231350        theory.name = "CoreShell" 
    13241351        theory.id = 4 
    13251352        theory.append_empty_process() 
    1326         process = theory.process[len(theory.process)-1] 
    1327         process.description = "this is my description" 
     1353        process1 = theory.process[len(theory.process)-1] 
     1354        process1.description = "this is my description" 
    13281355        path = "path3" 
    1329         data.append_empty_process() 
    1330         process = data.process[len(data.process)-1] 
    1331         process.data = "07/22/2010" 
    1332         data_list['4']=set_data_state(data, path,theory, state) 
     1356        data1.append_empty_process() 
     1357        process1 = data1.process[len(data1.process)-1] 
     1358        process1.data = "07/22/2010" 
     1359        data_list1['4'] = set_data_state(data1, path,theory, state1) 
    13331360        #state 4 
    13341361        temp_data_list = {} 
    1335         data.name = "data5 erasing data2" 
    1336         temp_data_list['4'] = set_data_state(data, path,theory, state) 
     1362        data1.name = "data5 erasing data2" 
     1363        temp_data_list['4'] = set_data_state(data1, path,theory, state1) 
    13371364        #state 5 
    1338         data = Data2D() 
    1339         data.name = "data3" 
    1340         data.id = 5 
    1341         data.append_empty_process() 
    1342         process = data.process[len(data.process)-1] 
    1343         process.data = "07/01/2010" 
     1365        data1 = Data2D() 
     1366        data1.name = "data3" 
     1367        data1.id = 5 
     1368        data1.append_empty_process() 
     1369        process1 = data.process[len(data1.process)-1] 
     1370        process1.data = "07/01/2010" 
    13441371        theory = Theory1D() 
    13451372        theory.name = "Cylinder" 
    13461373        path = "path2" 
    1347         state = State() 
    1348         dstate= set_data_state(data, path,theory, state) 
     1374        state1 = State() 
     1375        dstate= set_data_state(data, path,theory, state1) 
    13491376        theory = Theory1D() 
    13501377        theory.id = 6 
     
    13551382        theory.name = "CoreShell replacing coreshell in data3" 
    13561383        dstate.set_theory(theory) 
    1357         data_list['3'] = dstate 
     1384        data_list1['3'] = dstate 
    13581385        #state 6 
    1359         data_list['6']=set_data_state(None, path,theory, state) 
    1360         data_list['6']=set_data_state(theory=theory, state=None) 
     1386        data_list1['6'] = set_data_state(None, path, theory, state1) 
     1387        data_list1['6'] = set_data_state(theory=theory, state=None) 
    13611388        theory = Theory1D() 
    13621389        theory.id = 7 
    1363         data_list['6']=set_data_state(theory=theory, state=None) 
    1364         data_list['7']=set_data_state(theory=theory, state=None) 
    1365         window = DataFrame(list=data_list) 
    1366         window.load_data_list(list=data_list) 
     1390        data_list1['6'] = set_data_state(theory=theory, state=None) 
     1391        data_list1['7'] = set_data_state(theory=theory, state=None) 
     1392        window = DataFrame(list=data_list1) 
     1393        window.load_data_list(list=data_list1) 
    13671394        window.Show(True) 
    13681395        window.load_data_list(list=temp_data_list) 
    13691396    except: 
    13701397        #raise 
    1371         print "error",sys.exc_value 
     1398        print "error", sys.exc_value 
    13721399         
    13731400    app.MainLoop()   
Note: See TracChangeset for help on using the changeset viewer.