Changeset f668101 in sasview for src/sas/sasgui/guiframe


Ignore:
Timestamp:
Dec 7, 2016 7:16:33 AM (7 years ago)
Author:
jhbakker
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:
c6728e1
Parents:
1cad8a4 (diff), 5231948 (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 Jurtest

Location:
src/sas/sasgui/guiframe
Files:
5 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 
  • src/sas/sasgui/guiframe/gui_manager.py

    ra4c2445 rc8e1996  
    33""" 
    44################################################################################ 
    5 #This software was developed by the University of Tennessee as part of the 
    6 #Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
    7 #project funded by the US National Science Foundation. 
     5# This software was developed by the University of Tennessee as part of the 
     6# Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 
     7# project funded by the US National Science Foundation. 
    88# 
    9 #See the license text in license.txtz 
     9# See the license text in license.txtz 
    1010# 
    11 #copyright 2008, University of Tennessee 
     11# copyright 2008, University of Tennessee 
    1212################################################################################ 
    1313 
     
    2121import warnings 
    2222import re 
    23 warnings.simplefilter("ignore") 
    2423import logging 
    2524import httplib 
     
    4948from matplotlib import _pylab_helpers 
    5049 
     50warnings.simplefilter("ignore") 
     51 
    5152 
    5253def get_app_dir(): 
     
    8283    return app_path 
    8384 
     85 
    8486def get_user_directory(): 
    8587    """ 
     
    9092        os.makedirs(userdir) 
    9193    return userdir 
     94 
    9295 
    9396def _find_local_config(file, path): 
     
    113116 
    114117# GUI always starts from the App folder 
    115 #os.chdir(PATH_APP) 
     118# os.chdir(PATH_APP) 
    116119# Read in the local config, which can either be with the main 
    117120# application or in the installation directory 
     
    128131    logging.info("found local_config in %s" % PATH_APP) 
    129132 
    130 from sas.sasgui.guiframe.customdir  import SetupCustom 
     133from sas.sasgui.guiframe.customdir import SetupCustom 
    131134c_conf_dir = SetupCustom().setup_dir(PATH_APP) 
    132135custom_config = _find_local_config('custom_config', c_conf_dir) 
     
    141144    logging.info("using custom_config from %s" % c_conf_dir) 
    142145 
    143 #read some constants from config 
     146# read some constants from config 
    144147APPLICATION_STATE_EXTENSION = config.APPLICATION_STATE_EXTENSION 
    145148APPLICATION_NAME = config.__appname__ 
     
    169172    # custom open_path 
    170173    open_folder = custom_config.DEFAULT_OPEN_FOLDER 
    171     if open_folder != None and os.path.isdir(open_folder): 
     174    if open_folder is not None and os.path.isdir(open_folder): 
    172175        DEFAULT_OPEN_FOLDER = os.path.abspath(open_folder) 
    173176    else: 
     
    222225        CHILD_FRAME = wx.Frame 
    223226 
     227 
    224228class ViewerFrame(PARENT_FRAME): 
    225229    """ 
     
    235239        Initialize the Frame object 
    236240        """ 
    237         PARENT_FRAME.__init__(self, parent=parent, title=title, pos=pos, size=size) 
     241        PARENT_FRAME.__init__(self, parent=parent, title=title, 
     242                              pos=pos, size=size) 
    238243        # title 
    239244        self.title = title 
     
    256261        self.path = PATH_APP 
    257262        self.application_name = APPLICATION_NAME 
    258         ## Application manager 
     263        # Application manager 
    259264        self._input_file = None 
    260265        self.app_manager = None 
    261266        self._mgr = None 
    262         #add current perpsective 
     267        # add current perpsective 
    263268        self._current_perspective = None 
    264269        self._plotting_plugin = None 
    265270        self._data_plugin = None 
    266         #Menu bar and item 
     271        # Menu bar and item 
    267272        self._menubar = None 
    268273        self._file_menu = None 
     
    278283        self._toolbar_menu = None 
    279284        self._save_appl_menu = None 
    280         #tool bar 
     285        # tool bar 
    281286        self._toolbar = None 
    282287        # Status bar 
     
    286291        # plot duck cleanup option 
    287292        self.cleanup_plots = CLEANUP_PLOT 
    288         ## Find plug-ins 
     293        # Find plug-ins 
    289294        # Modify this so that we can specify the directory to look into 
    290295        self.plugins = [] 
    291         #add local plugin 
     296        # add local plugin 
    292297        self.plugins += self._get_local_plugins() 
    293298        self.plugins += self._find_plugins() 
    294         ## List of panels 
     299        # List of panels 
    295300        self.panels = {} 
    296301        # List of plot panels 
     
    304309        self.defaultPanel = None 
    305310        self.welcome_panel_class = None 
    306         #panel on focus 
     311        # panel on focus 
    307312        self.panel_on_focus = None 
    308         #control_panel on focus 
     313        # control_panel on focus 
    309314        self.cpanel_on_focus = None 
    310315 
    311316        self.loader = Loader() 
    312         #data manager 
     317        # data manager 
    313318        self.batch_on = False 
    314319        from sas.sasgui.guiframe.data_manager import DataManager 
    315320        self._data_manager = DataManager() 
    316         self._data_panel = None#DataPanel(parent=self) 
     321        self._data_panel = None  # DataPanel(parent=self) 
    317322        if self.panel_on_focus is not None: 
    318             self._data_panel.set_panel_on_focus(self.panel_on_focus.window_caption) 
     323            self._data_panel.set_panel_on_focus( 
     324                self.panel_on_focus.window_caption) 
    319325        # list of plot panels in schedule to full redraw 
    320326        self.schedule = False 
    321         #self.callback = True 
     327        # self.callback = True 
    322328        self._idle_count = 0 
    323329        self.schedule_full_draw_list = [] 
     
    333339        # Register to status events 
    334340        self.Bind(EVT_STATUS, self._on_status_event) 
    335         #Register add extra data on the same panel event on load 
     341        # Register add extra data on the same panel event on load 
    336342        self.Bind(EVT_PANEL_ON_FOCUS, self.set_panel_on_focus) 
    337343        self.Bind(EVT_APPEND_BOOKMARK, self.append_bookmark) 
     
    373379        # Adjust toolbar height 
    374380        toolbar = self.GetToolBar() 
    375         if toolbar != None: 
     381        if toolbar is not None: 
    376382            _, tb_h = toolbar.GetSizeTuple() 
    377383            height -= tb_h 
     
    386392                    fitpanel = item.fit_panel 
    387393 
    388         if fitpanel != None: 
     394        if fitpanel is not None: 
    389395            for i in range(0, fitpanel.GetPageCount()): 
    390396                fitpanel.GetPage(i)._populate_listbox() 
     
    413419        """ 
    414420        Display value of data into the application grid 
    415         :param data: dictionary of string and list of items 
     421        :param data_inputs: dictionary of string and list of items 
     422        :param details: descriptive string 
     423        :param file_name: file name 
     424        :param data_outputs: Data outputs 
    416425        """ 
    417426        self.batch_frame.set_data(data_inputs=data_inputs, 
     
    427436        """ 
    428437        path = None 
    429         if self._default_save_location == None: 
     438        if self._default_save_location is None: 
    430439            self._default_save_location = os.getcwd() 
    431440        wildcard = "(*.csv; *.txt)|*.csv; *.txt" 
     
    469478            line.strip() 
    470479            count = 0 
    471             if separator == None: 
     480            if separator is None: 
    472481                line.replace('\t', ' ') 
    473                 #found the first line containing the label 
     482                # found the first line containing the label 
    474483                col_name_toks = line.split() 
    475484                for item in col_name_toks: 
     
    480489            elif line.find(separator) != -1: 
    481490                if line.count(separator) >= 2: 
    482                     #found the first line containing the label 
     491                    # found the first line containing the label 
    483492                    col_name_toks = line.split(separator) 
    484493                    for item in col_name_toks: 
     
    534543            separator = "," 
    535544        fd.write(str(details)) 
    536         for col_name  in data.keys(): 
     545        for col_name in data.keys(): 
    537546            fd.write(str(col_name)) 
    538547            fd.write(separator) 
     
    597606        Set up custom configuration if exists 
    598607        """ 
    599         if custom_config == None: 
     608        if custom_config is None: 
    600609            return 
    601610 
     
    617626        Set default starting perspective 
    618627        """ 
    619         if custom_config == None: 
     628        if custom_config is None: 
    620629            return 
    621630        for plugin in self.plugins: 
     
    626635                    frame = plugin.get_frame() 
    627636                    frame.Show(True) 
    628                     #break 
     637                    # break 
    629638                else: 
    630639                    frame = plugin.get_frame() 
     
    683692            try: 
    684693                flag = self.panel_on_focus.get_save_flag() 
    685                 if self._save_appl_menu != None: 
     694                if self._save_appl_menu is not None: 
    686695                    self._save_appl_menu.Enable(flag) 
    687696 
     
    694703                                self.panel_on_focus is not None: 
    695704                    self.set_panel_on_focus_helper() 
    696                     #update toolbar 
     705                    # update toolbar 
    697706                    self._update_toolbar_helper() 
    698                     #update edit menu 
     707                    # update edit menu 
    699708                    self.enable_edit_menu() 
    700709            except wx._core.PyDeadObjectError: 
     
    711720        Send focusing on ID to data explorer 
    712721        """ 
    713         if self._data_panel != None: 
     722        if self._data_panel is not None: 
    714723            self._data_panel.set_panel_on_focus(name) 
    715724 
     
    720729        caption = self.panel_on_focus.window_caption 
    721730        self.send_focus_to_datapanel(caption) 
    722         #update combo 
     731        # update combo 
    723732        if self.panel_on_focus in self.plot_panels.values(): 
    724733            combo = self._data_panel.cb_plotpanel 
     
    739748        """ 
    740749        cpanel = panel 
    741         if self._toolbar != None and cpanel._bookmark_flag: 
    742             for item in  self._toolbar.get_bookmark_items(): 
     750        if self._toolbar is not None and cpanel._bookmark_flag: 
     751            for item in self._toolbar.get_bookmark_items(): 
    743752                self._toolbar.remove_bookmark_item(item) 
    744753            self._toolbar.add_bookmark_default() 
     
    841850        field = self.sb.get_msg_position() 
    842851        wx.Frame.PushStatusText(self, field=field, 
    843                                 string="FIXME - PushStatusText called without text") 
     852                                string= 
     853                                "FIXME - PushStatusText called without text") 
    844854 
    845855    def add_perspective(self, plugin): 
     
    866876        """ 
    867877        plugins = [] 
    868         #import guiframe local plugins 
    869         #check if the style contain guiframe.dataloader 
     878        # import guiframe local plugins 
     879        # check if the style contain guiframe.dataloader 
    870880        style1 = self.__gui_style & GUIFRAME.DATALOADER_ON 
    871881        style2 = self.__gui_style & GUIFRAME.PLOTTING_ON 
    872882        if style1 == GUIFRAME.DATALOADER_ON: 
    873883            try: 
    874                 from sas.sasgui.guiframe.local_perspectives.data_loader import data_loader 
     884                from sas.sasgui.guiframe.local_perspectives.data_loader \ 
     885                    import data_loader 
    875886                self._data_plugin = data_loader.Plugin() 
    876887                plugins.append(self._data_plugin) 
     
    881892        if style2 == GUIFRAME.PLOTTING_ON: 
    882893            try: 
    883                 from sas.sasgui.guiframe.local_perspectives.plotting import plotting 
     894                from sas.sasgui.guiframe.local_perspectives.plotting \ 
     895                    import plotting 
    884896                self._plotting_plugin = plotting.Plugin() 
    885897                plugins.append(self._plotting_plugin) 
     
    907919            else: 
    908920                file_list = [] 
    909             ## the default panel is the panel is the last plugin added 
     921            # the default panel is the panel is the last plugin added 
    910922            for item in file_list: 
    911923                toks = os.path.splitext(os.path.basename(item)) 
     
    914926                    if toks[1] == '.py' or toks[1] == '': 
    915927                        name = toks[0] 
    916                     #check the validity of the module name parsed 
    917                     #before trying to import it 
     928                    # check the validity of the module name parsed 
     929                    # before trying to import it 
    918930                    if name is None or name.strip() == '': 
    919931                        continue 
     
    941953                        logging.error(msg) 
    942954                    finally: 
    943                         if not file == None: 
     955                        if file is not None: 
    944956                            file.close() 
    945957        except: 
     
    956968        """ 
    957969        self._window_width, self._window_height = self.get_client_size() 
    958         ## Default size 
     970        # Default size 
    959971        if DATAPANEL_WIDTH < 0: 
    960972            panel_width = int(self._window_width * 0.25) 
     
    962974            panel_width = DATAPANEL_WIDTH 
    963975        panel_height = int(self._window_height) 
    964         if self._data_panel is not None  and (p == self._data_panel): 
     976        if self._data_panel is not None and (p == self._data_panel): 
    965977            return panel_width, panel_height 
    966978        if hasattr(p, "CENTER_PANE") and p.CENTER_PANE: 
     
    9941006        if self.welcome_panel_class is not None: 
    9951007            welcome_panel = MDIFrame(self, None, 'None', (100, 200)) 
    996             self.defaultPanel = self.welcome_panel_class(welcome_panel, -1, style=wx.RAISED_BORDER) 
     1008            self.defaultPanel = self.welcome_panel_class(welcome_panel, -1, 
     1009                                                         style=wx.RAISED_BORDER) 
    9971010            welcome_panel.set_panel(self.defaultPanel) 
    9981011            self.defaultPanel.set_frame(welcome_panel) 
     
    10101023                frame.SetPosition((0, mac_pos_y + size_t_bar)) 
    10111024            frame.Show(True) 
    1012         #add data panel 
     1025        # add data panel 
    10131026        win = MDIFrame(self, None, 'None', (100, 200)) 
    10141027        data_panel = DataPanel(parent=win, id=-1) 
     
    10181031        d_panel_width, h = self._get_panels_size(self._data_panel) 
    10191032        win.SetSize((d_panel_width, h)) 
    1020         is_visible = self.__gui_style & GUIFRAME.MANAGER_ON == GUIFRAME.MANAGER_ON 
     1033        is_visible = self.__gui_style & \ 
     1034                     GUIFRAME.MANAGER_ON == GUIFRAME.MANAGER_ON 
    10211035        if IS_WIN: 
    10221036            win.SetPosition((0, 0)) 
     
    10641078        Update the data. 
    10651079        """ 
    1066         prev_id, data_state = self._data_manager.update_data( \ 
     1080        prev_id, data_state = self._data_manager.update_data( 
    10671081                              prev_data=prev_data, new_data=new_data) 
    10681082 
     
    11151129        self._current_perspective.delete_data(data) 
    11161130 
    1117  
    11181131    def get_context_menu(self, plotpanel=None): 
    11191132        """ 
     
    11391152        menu_list = [] 
    11401153        item = self._current_perspective 
    1141         if item != None: 
     1154        if item is not None: 
    11421155            menu_list.extend(item.get_context_menu(plotpanel=plotpanel)) 
    11431156        return menu_list 
     
    11581171            self.cpanel_on_focus.SetFocus() 
    11591172 
    1160  
    11611173    def popup_panel(self, p): 
    11621174        """ 
     
    11701182        ID = wx.NewId() 
    11711183        self.panels[str(ID)] = p 
    1172         ## Check and set the size 
     1184        # Check and set the size 
    11731185        if PLOPANEL_WIDTH < 0: 
    11741186            p_panel_width = int(self._window_width * 0.45) 
     
    12091221        # Register for showing/hiding the panel 
    12101222        wx.EVT_MENU(self, ID, self.on_view) 
    1211         if p not in self.plot_panels.values() and p.group_id != None: 
     1223        if p not in self.plot_panels.values() and p.group_id is not None: 
    12121224            self.plot_panels[ID] = p 
    12131225            if len(self.plot_panels) == 1: 
     
    12151227                self.set_panel_on_focus(None) 
    12161228            if self._data_panel is not None and \ 
    1217                 self._plotting_plugin is not None: 
     1229                            self._plotting_plugin is not None: 
    12181230                ind = self._data_panel.cb_plotpanel.FindString('None') 
    12191231                if ind != wx.NOT_FOUND: 
     
    12581270        panel_name = 'No Panel on Focus' 
    12591271        c_panel = self.cpanel_on_focus 
    1260         if self._toolbar is  None: 
     1272        if self._toolbar is None: 
    12611273            return 
    12621274        if c_panel is not None: 
     
    13031315        """ 
    13041316        if self._menubar is None or self._current_perspective is None \ 
    1305             or self._menubar.GetMenuCount() == 0: 
     1317                or self._menubar.GetMenuCount() == 0: 
    13061318            return 
    1307         #replace or add a new menu for the current plugin 
     1319        # replace or add a new menu for the current plugin 
    13081320        pos = self._menubar.FindMenu(str(self._applications_menu_name)) 
    13091321        if pos == -1 and self._applications_menu_pos > 0: 
     
    13251337                for (menu, name) in menu_list: 
    13261338                    if self._applications_menu_pos == -1: 
    1327                         # Find the Analysis position and insert just after it if possible 
     1339                        # Find the Analysis position and insert just after it 
    13281340                        analysis_pos = self._menubar.FindMenu("Analysis") 
    13291341                        if analysis_pos == -1: 
     
    13341346                            self._applications_menu_pos = analysis_pos + 1 
    13351347                    else: 
    1336                         self._menubar.Insert(self._applications_menu_pos, menu, name) 
     1348                        self._menubar.Insert(self._applications_menu_pos, 
     1349                                             menu, name) 
    13371350                    self._applications_menu_name = name 
    13381351 
     
    13621375        if config._do_acknowledge: 
    13631376            wx_id = wx.NewId() 
    1364             self._help_menu.Append(wx_id, '&Acknowledge', 'Acknowledging SasView') 
     1377            self._help_menu.Append(wx_id, '&Acknowledge', 
     1378                                   'Acknowledging SasView') 
    13651379            wx.EVT_MENU(self, wx_id, self._onAcknowledge) 
    13661380 
     
    13791393        wx_id = wx.NewId() 
    13801394        self._help_menu.Append(wx_id, '&Check for update', 
    1381                                'Check for the latest version of %s' % config.__appname__) 
     1395                               'Check for the latest version of %s' % 
     1396                               config.__appname__) 
    13821397        wx.EVT_MENU(self, wx_id, self._check_update) 
    13831398        self._menubar.Append(self._help_menu, '&Help') 
     
    14001415        wx_id = wx.NewId() 
    14011416        self._data_panel_menu = self._view_menu.Append(wx_id, 
    1402                                                        '&Show Data Explorer', '') 
     1417                                                       '&Show Data Explorer', 
     1418                                                       '') 
    14031419        wx.EVT_MENU(self, wx_id, self.show_data_panel) 
    14041420        if style == GUIFRAME.MANAGER_ON: 
     
    14111427        style1 = self.__gui_style & GUIFRAME.TOOLBAR_ON 
    14121428        if style1 == GUIFRAME.TOOLBAR_ON: 
    1413             self._toolbar_menu = self._view_menu.Append(wx_id, '&Hide Toolbar', '') 
     1429            self._toolbar_menu = self._view_menu.Append(wx_id, '&Hide Toolbar', 
     1430                                                        '') 
    14141431        else: 
    1415             self._toolbar_menu = self._view_menu.Append(wx_id, '&Show Toolbar', '') 
     1432            self._toolbar_menu = self._view_menu.Append(wx_id, '&Show Toolbar', 
     1433                                                        '') 
    14161434        wx.EVT_MENU(self, wx_id, self._on_toggle_toolbar) 
    14171435 
    1418         if custom_config != None: 
     1436        if custom_config is not None: 
    14191437            self._view_menu.AppendSeparator() 
    14201438            wx_id = wx.NewId() 
     
    14271445        wx_id = wx.NewId() 
    14281446        self._view_menu.AppendSeparator() 
    1429         self._view_menu.Append(wx_id, 'Category Manager', 'Edit model categories') 
     1447        self._view_menu.Append(wx_id, 'Category Manager', 
     1448                               'Edit model categories') 
    14301449        wx.EVT_MENU(self, wx_id, self._on_category_manager) 
    14311450 
     
    14401459        self.batch_frame.Show(True) 
    14411460 
    1442     def  on_category_panel(self, event): 
     1461    def on_category_panel(self, event): 
    14431462        """ 
    14441463        On cat panel 
     
    14591478        """ 
    14601479        from sas.sasgui.guiframe.startup_configuration \ 
    1461         import StartupConfiguration as ConfDialog 
     1480            import StartupConfiguration as ConfDialog 
    14621481 
    14631482        dialog = ConfDialog(parent=self, gui=self.__gui_style) 
     
    14661485            dialog.write_custom_config() 
    14671486            # post event for info 
    1468             wx.PostEvent(self, StatusEvent(status="Wrote custom configuration", info='info')) 
     1487            wx.PostEvent(self, StatusEvent(status="Wrote custom configuration", 
     1488                                           info='info')) 
    14691489        dialog.Destroy() 
    14701490 
     
    14851505                    id = wx.NewId() 
    14861506                    if plug.use_data(): 
    1487                         self._applications_menu.InsertCheckItem(pos, id, plug.sub_menu, \ 
    1488                             "Switch to analysis: %s" % plug.sub_menu) 
     1507                        self._applications_menu.InsertCheckItem(pos, id, 
     1508                                                                plug.sub_menu, 
     1509                                    "Switch to analysis: %s" % plug.sub_menu) 
    14891510                        plug_data_count = True 
    14901511                        pos += 1 
    14911512                    else: 
    14921513                        plug_no_data_count = True 
    1493                         self._applications_menu.AppendCheckItem(id, plug.sub_menu, \ 
     1514                        self._applications_menu.AppendCheckItem(id, 
     1515                                                                plug.sub_menu, 
    14941516                            "Switch to analysis: %s" % plug.sub_menu) 
    14951517                    wx.EVT_MENU(self, id, plug.on_perspective) 
     
    14971519            if not plug_data_count or not plug_no_data_count: 
    14981520                self._applications_menu.RemoveItem(separator) 
    1499             #Windows introduces a "Window" menu item during the layout process 
    1500             #somehow.  We want it to be next to the last item with Help as 
    1501             #last. However Analysis gets stuck after Window in normal ordering 
    1502             #so force it to be next after the Tools menu item.  Should we add 
    1503             #another menu item will need to check if this is still where we  
    1504             #want Analysis.  This is NOT an issue on the Mac which does not 
    1505             #have the extra Window menu item. 
     1521            # Windows introduces a "Window" menu item during the layout process 
     1522            # somehow.  We want it to be next to the last item with Help as 
     1523            # last. However Analysis gets stuck after Window in normal ordering 
     1524            # so force it to be next after the Tools menu item.  Should we add 
     1525            # another menu item will need to check if this is still where we 
     1526            # want Analysis.  This is NOT an issue on the Mac which does not 
     1527            # have the extra Window menu item. 
    15061528            #      March 2016 Code Camp  -- PDB  
    15071529            Tools_pos = self._menubar.FindMenu("Tools") 
    1508             self._menubar.Insert(Tools_pos+1,self._applications_menu, 
     1530            self._menubar.Insert(Tools_pos+1, self._applications_menu, 
    15091531                                 '&Analysis') 
    15101532            self._check_applications_menu() 
     
    15271549            wx_id = wx.NewId() 
    15281550            hint_load_file = "read all analysis states saved previously" 
    1529             self._save_appl_menu = self._file_menu.Append(wx_id, '&Open Project', hint_load_file) 
     1551            self._save_appl_menu = self._file_menu.Append(wx_id, 
     1552                                                          '&Open Project', 
     1553                                                          hint_load_file) 
    15301554            wx.EVT_MENU(self, wx_id, self._on_open_state_project) 
    15311555 
     
    15361560            wx_id = wx.NewId() 
    15371561            self._save_appl_menu = self._file_menu.Append(wx_id, 
    1538                                                           '&Open Analysis', hint_load_file) 
     1562                                                          '&Open Analysis', 
     1563                                                          hint_load_file) 
    15391564            wx.EVT_MENU(self, wx_id, self._on_open_state_application) 
    15401565        if OPEN_SAVE_MENU: 
     
    15461571        if style1 == GUIFRAME.MULTIPLE_APPLICATIONS: 
    15471572            wx_id = wx.NewId() 
    1548             self._save_appl_menu = self._file_menu.Append(wx_id, \ 
    1549                 '&Save Analysis', 'Save state of the current active analysis panel') 
     1573            txt = '&Save Analysis' 
     1574            txt2 = 'Save state of the current active analysis panel' 
     1575            self._save_appl_menu = self._file_menu.Append(wx_id, txt, txt2) 
    15501576            wx.EVT_MENU(self, wx_id, self._on_save_application) 
    15511577        if not sys.platform == 'darwin': 
     
    15891615 
    15901616        self._edit_menu_copyas = wx.Menu() 
    1591         #Sub menu for Copy As... 
    1592         self._edit_menu_copyas.Append(GUIFRAME_ID.COPYEX_ID, 'Copy current tab to Excel', 
     1617        # Sub menu for Copy As... 
     1618        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYEX_ID, 
     1619                                      'Copy current tab to Excel', 
    15931620                                      'Copy parameter values in tabular format') 
    15941621        wx.EVT_MENU(self, GUIFRAME_ID.COPYEX_ID, self.on_copy_panel) 
    15951622 
    1596         self._edit_menu_copyas.Append(GUIFRAME_ID.COPYLAT_ID, 'Copy current tab to LaTeX', 
     1623        self._edit_menu_copyas.Append(GUIFRAME_ID.COPYLAT_ID, 
     1624                                      'Copy current tab to LaTeX', 
    15971625                                      'Copy parameter values in tabular format') 
    15981626        wx.EVT_MENU(self, GUIFRAME_ID.COPYLAT_ID, self.on_copy_panel) 
    1599  
    16001627 
    16011628        self._edit_menu.AppendMenu(GUIFRAME_ID.COPYAS_ID, 'Copy Params as...', 
     
    16201647        Return the gui style 
    16211648        """ 
    1622         return  self.__gui_style 
     1649        return self.__gui_style 
    16231650 
    16241651    def _add_menu_data(self): 
     
    16751702            return 
    16761703        frame = self.panels['default'].get_frame() 
    1677         if frame == None: 
     1704        if frame is None: 
    16781705            return 
    16791706        # Show default panel 
     
    17081735                self.schedule_full_draw_list.remove(panel) 
    17091736 
    1710             #delete uid number not str(uid) 
     1737            # delete uid number not str(uid) 
    17111738            if ID in self.plot_panels.keys(): 
    17121739                del self.plot_panels[ID] 
     
    17341761            return 
    17351762 
    1736         #reading a state file 
     1763        # reading a state file 
    17371764        for plug in self.plugins: 
    17381765            reader, ext = plug.get_extensions() 
    17391766            if reader is not None: 
    1740                 #read the state of the single plugin 
     1767                # read the state of the single plugin 
    17411768                if extension == ext: 
    17421769                    reader.read(path) 
     
    17491776                        msg += "\n(%s)" % sys.exc_value 
    17501777                        wx.PostEvent(self, StatusEvent(status=msg, 
    1751                                                        info="error", type="stop")) 
     1778                                                       info="error", 
     1779                                                       type="stop")) 
    17521780                        return 
    17531781 
     
    17881816            basename = os.path.basename(path) 
    17891817            if APPLICATION_STATE_EXTENSION is not None \ 
    1790                 and basename.endswith(APPLICATION_STATE_EXTENSION): 
     1818                    and basename.endswith(APPLICATION_STATE_EXTENSION): 
    17911819                if is_project: 
    17921820                    for ID in self.plot_panels.keys(): 
     
    18581886        """ 
    18591887        path = None 
    1860         if self._default_save_location == None: 
     1888        if self._default_save_location is None: 
    18611889            self._default_save_location = os.getcwd() 
    18621890        wx.PostEvent(self, StatusEvent(status="Loading Analysis file...")) 
     
    18921920                    break 
    18931921            # Found the extension 
    1894             if ind != None: 
     1922            if ind is not None: 
    18951923                plug_wlist.remove(ind) 
    18961924                plug_wlist.insert(0, ind) 
     
    19101938        """ 
    19111939        path = None 
    1912         if self._default_save_location == None: 
     1940        if self._default_save_location is None: 
    19131941            self._default_save_location = os.getcwd() 
    19141942        msg = "This operation will set remove all data, plots and analyses from" 
    19151943        msg += " SasView before loading the project. Do you wish to continue?" 
    1916         self._data_panel.selection_cbox.SetValue('Select all Data') 
    1917         self._data_panel._on_selection_type(None) 
    1918         for _, theory_dict in self._data_panel.list_cb_theory.iteritems(): 
    1919             for  key, value in theory_dict.iteritems(): 
    1920                 item, _, _ = value 
    1921                 item.Check(True) 
    1922         if not self._data_panel.on_remove(None, msg): 
     1944        msg_box = wx.MessageDialog(None, msg, 'Warning', wx.OK | wx.CANCEL) 
     1945        if msg_box.ShowModal() == wx.ID_OK: 
     1946            self._data_panel.selection_cbox.SetValue('Select all Data') 
     1947            self._data_panel._on_selection_type(None) 
     1948            for _, theory_dict in self._data_panel.list_cb_theory.iteritems(): 
     1949                for key, value in theory_dict.iteritems(): 
     1950                    item, _, _ = value 
     1951                    item.Check(True) 
     1952            self._data_panel.on_remove(None, False) 
     1953 
    19231954            wx.PostEvent(self, StatusEvent(status="Loading Project file...")) 
    1924             dlg = wx.FileDialog(self, 
    1925                             "Choose a file", 
    1926                             self._default_save_location, "", 
    1927                             APPLICATION_WLIST) 
     1955            dlg = wx.FileDialog(self, "Choose a file", 
     1956                                self._default_save_location, "", 
     1957                                APPLICATION_WLIST) 
    19281958            if dlg.ShowModal() == wx.ID_OK: 
    19291959                path = dlg.GetPath() 
     
    19691999        save the state of the SasView as *.svs 
    19702000        """ 
    1971         if self._current_perspective is  None: 
     2001        if self._current_perspective is None: 
    19722002            return 
    19732003        wx.PostEvent(self, StatusEvent(status="Saving Project file...")) 
     
    19972027            extens = APPLICATION_STATE_EXTENSION 
    19982028            fName = os.path.splitext(path)[0] + extens 
    1999             if doc != None: 
     2029            if doc is not None: 
    20002030                fd = open(fName, 'w') 
    20012031                fd.write(doc.toprettyxml()) 
     
    20292059                    if data is not None: 
    20302060                        new_doc = reader.write_toXML(data, state) 
    2031                         if doc != None and hasattr(doc, "firstChild"): 
     2061                        if doc is not None and hasattr(doc, "firstChild"): 
    20322062                            child = new_doc.firstChild.firstChild 
    20332063                            doc.firstChild.appendChild(child) 
     
    20402070                if data is not None: 
    20412071                    new_doc = reader.write_toXML(data, state) 
    2042                     if doc != None and hasattr(doc, "firstChild"): 
     2072                    if doc is not None and hasattr(doc, "firstChild"): 
    20432073                        child = new_doc.firstChild.firstChild 
    20442074                        doc.firstChild.appendChild(child) 
     
    20952125            except: 
    20962126                logging.info("Failed to connect to www.sasview.org") 
    2097         self._process_version(version_info, standalone=event == None) 
     2127        self._process_version(version_info, standalone=event is None) 
    20982128 
    20992129    def _process_version(self, version_info, standalone=True): 
     
    21842214                    try: 
    21852215                        # Try an alternate method 
    2186                         logging.error("Could not open the tutorial pdf, trying xhtml2pdf") 
     2216                        logging.error( 
     2217                            "Could not open the tutorial pdf, trying xhtml2pdf") 
    21872218                        from xhtml2pdf import pisa 
    21882219                        pisa.startViewer(path) 
    21892220                    except: 
    2190                         logging.error("Could not open the tutorial pdf with xhtml2pdf") 
     2221                        logging.error( 
     2222                            "Could not open the tutorial pdf with xhtml2pdf") 
    21912223                        msg = "This feature requires 'PDF Viewer'\n" 
    21922224                        wx.MessageBox(msg, 'Error') 
     
    21982230                    try: 
    21992231                        # Try an alternate method 
    2200                         logging.error("Could not open the tutorial pdf, trying xhtml2pdf") 
     2232                        logging.error( 
     2233                            "Could not open the tutorial pdf, trying xhtml2pdf") 
    22012234                        from xhtml2pdf import pisa 
    22022235                        pisa.startViewer(path) 
    22032236                    except: 
    2204                         logging.error("Could not open the tutorial pdf with xhtml2pdf") 
    2205                         msg = "This feature requires the 'Preview' application\n" 
     2237                        logging.error( 
     2238                            "Could not open the tutorial pdf with xhtml2pdf") 
     2239                        msg = "This feature requires the Preview application\n" 
    22062240                        wx.MessageBox(msg, 'Error') 
    22072241 
     
    22182252        from documentation_window import DocumentationWindow 
    22192253        _TreeLocation = "user/user.html" 
    2220         DocumentationWindow(self, -1, _TreeLocation, "", "SasView Documentation") 
     2254        DocumentationWindow(self, -1, _TreeLocation, "", 
     2255                            "SasView Documentation") 
    22212256 
    22222257    def set_manager(self, manager): 
     
    22522287                if self.panels[item].ALWAYS_ON: 
    22532288                    continue 
    2254             if self.panels[item] == None: 
     2289            if self.panels[item] is None: 
    22552290                continue 
    22562291            if self.panels[item].window_name in panels: 
     
    22612296                # always show the data panel if enable 
    22622297                style = self.__gui_style & GUIFRAME.MANAGER_ON 
    2263                 if (style == GUIFRAME.MANAGER_ON) and self.panels[item] == self._data_panel: 
     2298                if (style == GUIFRAME.MANAGER_ON) \ 
     2299                        and self.panels[item] == self._data_panel: 
    22642300                    if 'data_panel' in self.panels.keys(): 
    22652301                        frame = self.panels['data_panel'].get_frame() 
    2266                         if frame == None: 
     2302                        if frame is None: 
    22672303                            continue 
    22682304                        flag = frame.IsShown() 
     
    22702306                else: 
    22712307                    frame = self.panels[item].get_frame() 
    2272                     if frame == None: 
     2308                    if frame is None: 
    22732309                        continue 
    22742310 
     
    22802316        show the data panel 
    22812317        """ 
    2282         if self._data_panel_menu == None: 
     2318        if self._data_panel_menu is None: 
    22832319            return 
    22842320        label = self._data_panel_menu.GetText() 
     
    23102346        :param data_list: dictionary of data's ID and value Data 
    23112347        """ 
    2312         #Store data into manager 
     2348        # Store data into manager 
    23132349        self.add_data_helper(data_list) 
    23142350        # set data in the data panel 
     
    23162352            data_state = self._data_manager.get_data_state(data_list.keys()) 
    23172353            self._data_panel.load_data_list(data_state) 
    2318         #if the data panel is shown wait for the user to press a button 
    2319         #to send data to the current perspective. if the panel is not 
    2320         #show  automatically send the data to the current perspective 
     2354        # if the data panel is shown wait for the user to press a button 
     2355        # to send data to the current perspective. if the panel is not 
     2356        # show  automatically send the data to the current perspective 
    23212357        style = self.__gui_style & GUIFRAME.MANAGER_ON 
    23222358        if style == GUIFRAME.MANAGER_ON: 
    2323             #wait for button press from the data panel to set_data 
     2359            # wait for button press from the data panel to set_data 
    23242360            if self._data_panel is not None: 
    23252361                self._data_panel.frame.Show(True) 
    23262362        else: 
    2327             #automatically send that to the current perspective 
     2363            # automatically send that to the current perspective 
    23282364            self.set_data(data_id=data_list.keys()) 
    23292365 
     
    23862422                                                       info='warning')) 
    23872423            else: 
    2388                 #if not append then new plot 
     2424                # if not append then new plot 
    23892425                from sas.sasgui.guiframe.dataFitting import Data2D 
    23902426                if issubclass(Data2D, new_plot.__class__): 
    2391                     #for 2 D always plot in a separated new plot 
     2427                    # for 2 D always plot in a separated new plot 
    23922428                    new_plot.group_id = wx.NewId() 
    23932429                else: 
     
    24202456                                                group_id=group_id, 
    24212457                                                action='remove')) 
    2422                 #remove res plot: Todo: improve 
     2458                # remove res plot: Todo: improve 
    24232459                wx.CallAfter(self._remove_res_plot, new_plot.id) 
    24242460        self._data_manager.delete_data(data_id=data_id, 
     
    24622498            mypath = os.path.basename(path) 
    24632499 
    2464             #Instantiate a loader 
     2500            # Instantiate a loader 
    24652501            loader = Loader() 
    24662502            ext_format = ".txt" 
     
    24822518        dlg.Destroy() 
    24832519 
    2484  
    24852520    def _onsaveTXT(self, data, path): 
    24862521        """ 
     
    24892524        .. todo:: Refactor and remove this method. See 'TODO' in _onSave. 
    24902525        """ 
    2491         if not path == None: 
     2526        if path is not None: 
    24922527            out = open(path, 'w') 
    24932528            has_errors = True 
    2494             if data.dy == None or data.dy == []: 
     2529            if data.dy is None or data.dy == []: 
    24952530                has_errors = False 
    24962531            # Sanity check 
     
    25022537                    has_errors = False 
    25032538            if has_errors: 
    2504                 if data.dx != None and data.dx != []: 
     2539                if data.dx is not None and data.dx != []: 
    25052540                    out.write("<X>   <Y>   <dY>   <dX>\n") 
    25062541                else: 
     
    25112546            for i in range(len(data.x)): 
    25122547                if has_errors: 
    2513                     if data.dx != None and data.dx != []: 
    2514                         if  data.dx[i] != None: 
     2548                    if data.dx is not None and data.dx != []: 
     2549                        if data.dx[i] is not None: 
    25152550                            out.write("%g  %g  %g  %g\n" % (data.x[i], 
    25162551                                                            data.y[i], 
     
    25432578                                           info="error")) 
    25442579            raise ValueError, msg 
    2545         ## text = str(data) 
     2580        # text = str(data) 
    25462581        text = data.__str__() 
    25472582        text += 'Data Min Max:\n' 
    25482583        text += 'X_min = %s:  X_max = %s\n' % (xmin, max(data.x)) 
    25492584        text += 'Y_min = %s:  Y_max = %s\n' % (ymin, max(data.y)) 
    2550         if data.dy != None: 
     2585        if data.dy is not None: 
    25512586            text += 'dY_min = %s:  dY_max = %s\n' % (min(data.dy), max(data.dy)) 
    25522587        text += '\nData Points:\n' 
    25532588        x_st = "X" 
    25542589        for index in range(len(data.x)): 
    2555             if data.dy != None and len(data.dy) > index: 
     2590            if data.dy is not None and len(data.dy) > index: 
    25562591                dy_val = data.dy[index] 
    25572592            else: 
    25582593                dy_val = 0.0 
    2559             if data.dx != None and len(data.dx) > index: 
     2594            if data.dx is not None and len(data.dx) > index: 
    25602595                dx_val = data.dx[index] 
    25612596            else: 
    25622597                dx_val = 0.0 
    2563             if data.dxl != None and len(data.dxl) > index: 
     2598            if data.dxl is not None and len(data.dxl) > index: 
    25642599                if index == 0: 
    25652600                    x_st = "Xl" 
    25662601                dx_val = data.dxl[index] 
    2567             elif data.dxw != None and len(data.dxw) > index: 
     2602            elif data.dxw is not None and len(data.dxw) > index: 
    25682603                if index == 0: 
    25692604                    x_st = "Xw" 
     
    26052640            mypath = os.path.basename(path) 
    26062641 
    2607             #Instantiate a loader 
     2642            # Instantiate a loader 
    26082643            loader = Loader() 
    26092644 
     
    26422677            y_val = data.qy_data[index] 
    26432678            i_val = data.data[index] 
    2644             if data.err_data != None: 
     2679            if data.err_data is not None: 
    26452680                di_val = data.err_data[index] 
    2646             if data.dqx_data != None: 
     2681            if data.dqx_data is not None: 
    26472682                dx_val = data.dqx_data[index] 
    2648             if data.dqy_data != None: 
     2683            if data.dqy_data is not None: 
    26492684                dy_val = data.dqy_data[index] 
    26502685 
     
    26812716                    for name in self._current_perspective.get_perspective(): 
    26822717                        frame = panel.get_frame() 
    2683                         if frame != None: 
     2718                        if frame is not None: 
    26842719                            if name == panel.window_name: 
    26852720                                panel.on_set_focus(event=None) 
     
    26912726                self._data_panel.set_active_perspective(name) 
    26922727                self._check_applications_menu() 
    2693             #Set the SasView title 
     2728            # Set the SasView title 
    26942729            self._set_title_name(name) 
    26952730 
     
    27232758        """ 
    27242759 
    2725         if self.panel_on_focus not in self._plotting_plugin.plot_panels.values(): 
     2760        if self.panel_on_focus \ 
     2761                not in self._plotting_plugin.plot_panels.values(): 
    27262762            return 
     2763        check = "Theory1D" 
    27272764        is_theory = len(self.panel_on_focus.plots) <= 1 and \ 
    2728             self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D" 
     2765            self.panel_on_focus.plots.values()[0].__class__.__name__ == check 
    27292766 
    27302767        is_data2d = hasattr(new_plot, 'data') 
     
    27342771        has_meta_data = hasattr(new_plot, 'meta_data') 
    27352772 
    2736         #disable_add_data if the data is being recovered from  a saved state file. 
     2773        # disable_add_data if the data is being recovered from  a saved state 
    27372774        is_state_data = False 
    27382775        if has_meta_data: 
    27392776            if 'invstate' in new_plot.meta_data: 
    27402777                is_state_data = True 
    2741             if  'prstate' in new_plot.meta_data: 
     2778            if 'prstate' in new_plot.meta_data: 
    27422779                is_state_data = True 
    2743             if  'fitstate' in new_plot.meta_data: 
     2780            if 'fitstate' in new_plot.meta_data: 
    27442781                is_state_data = True 
    27452782 
    2746         return is_data1d and not is_data2d and not is_theory and not is_state_data 
     2783        return is_data1d and not is_data2d and not is_theory \ 
     2784               and not is_state_data 
    27472785 
    27482786    def check_multimode(self, perspective=None): 
     
    27502788        Check the perspective have batch mode capablitity 
    27512789        """ 
    2752         if perspective == None or self._data_panel == None: 
     2790        if perspective is None or self._data_panel is None: 
    27532791            return 
    27542792        flag = perspective.get_batch_capable() 
     
    27772815            self._edit_menu.Enable(GUIFRAME_ID.PASTE_ID, flag) 
    27782816 
    2779             #Copy menu 
     2817            # Copy menu 
    27802818            flag = self.cpanel_on_focus.get_copy_flag() 
    27812819            self._edit_menu_copyas.Enable(GUIFRAME_ID.COPYEX_ID, flag) 
     
    29082946            if data_panel.cb_plotpanel is not None: 
    29092947                # Check if any panel has the same caption 
    2910                 has_newstring = data_panel.cb_plotpanel.FindString\ 
    2911                                                             (str(new_caption)) 
     2948                has_newstring = data_panel.cb_plotpanel.FindString( 
     2949                    str(new_caption)) 
    29122950                caption = new_caption 
    29132951                if has_newstring != wx.NOT_FOUND: 
     
    30263064        drag 
    30273065        """ 
    3028         #Not implemeted 
     3066        # Not implemeted 
    30293067 
    30303068    def enable_reset(self): 
     
    30393077        """ 
    30403078        size_y = 0 
    3041         if self.GetToolBar() != None and self.GetToolBar().IsShown(): 
     3079        if self.GetToolBar() is not None and self.GetToolBar().IsShown(): 
    30423080            if not IS_LINUX: 
    30433081                _, size_y = self.GetToolBar().GetSizeTuple() 
     
    30543092        # append this panel in the schedule list if not in yet 
    30553093        if func == 'append': 
    3056             if not panel in self.schedule_full_draw_list: 
     3094            if panel not in self.schedule_full_draw_list: 
    30573095                self.schedule_full_draw_list.append(panel) 
    30583096        # remove this panel from schedule list 
     
    30743112 
    30753113        count = len(self.schedule_full_draw_list) 
    3076         #if not self.schedule: 
     3114        # if not self.schedule: 
    30773115        if count < 1: 
    30783116            self.set_schedule(False) 
     
    30893127                if ind == count: 
    30903128                    return 
    3091         #Simple redraw only for a panel shown 
     3129        # Simple redraw only for a panel shown 
     3130 
    30923131        def f_draw(panel): 
    30933132            """ 
     
    31023141                    # draw if possible 
    31033142                    panel.set_resizing(False) 
    3104                     #panel.Show(True) 
     3143                    # panel.Show(True) 
    31053144                    panel.draw_plot() 
    31063145                # Check if the panel is not shown 
     
    31373176        Set focus on a plot panel 
    31383177        """ 
    3139         if panel == None: 
     3178        if panel is None: 
    31403179            return 
    3141         #self.set_plot_unfocus() 
     3180        # self.set_plot_unfocus() 
    31423181        panel.on_set_focus(None) 
    31433182        # set focusing panel 
     
    31723211        try: 
    31733212            # check if it is time to redraw 
    3174             if self.GetCapture() == None: 
     3213            if self.GetCapture() is None: 
    31753214                # Draw plot, changes resizing too 
    31763215                self.full_draw() 
     
    31803219        # restart idle 
    31813220        self._redraw_idle(*args, **kwargs) 
    3182  
    31833221 
    31843222    def _redraw_idle(self, *args, **kwargs): 
     
    31953233    the GUI manager 
    31963234    """ 
    3197     ## Internal nickname for the window, used by the AUI manager 
     3235    # Internal nickname for the window, used by the AUI manager 
    31983236    window_name = "default" 
    3199     ## Name to appear on the window title bar 
     3237    # Name to appear on the window title bar 
    32003238    window_caption = "Welcome panel" 
    3201     ## Flag to tell the AUI manager to put this panel in the center pane 
     3239    # Flag to tell the AUI manager to put this panel in the center pane 
    32023240    CENTER_PANE = True 
     3241 
    32033242    def __init__(self, parent, *args, **kwds): 
    32043243        wx.Panel.__init__(self, parent, *args, **kwds) 
    32053244        PanelBase.__init__(self, parent) 
    3206  
    32073245 
    32083246 
     
    32363274        try: 
    32373275            if os.path.isfile(SPLASH_SCREEN_PATH): 
    3238                 self.s_screen = self.display_splash_screen(parent=self.frame, 
    3239                                                            path=SPLASH_SCREEN_PATH) 
     3276                self.s_screen = \ 
     3277                    self.display_splash_screen(parent=self.frame, 
     3278                                               path=SPLASH_SCREEN_PATH) 
    32403279            else: 
    32413280                self.frame.Show() 
     
    33003339                            os.remove(file_path) 
    33013340                except: 
    3302                     logging.error("gui_manager.clean_plugin_models:\n  %s" \ 
     3341                    logging.error("gui_manager.clean_plugin_models:\n  %s" 
    33033342                                  % sys.exc_value) 
    33043343 
     
    33143353        Build the GUI 
    33153354        """ 
    3316         #try to load file at the start 
     3355        # try to load file at the start 
    33173356        self.open_file() 
    33183357        self.frame.build_gui() 
     
    33903429        # Return the suggested position and size for the application frame. 
    33913430        return (posX, posY), (customWidth, customHeight), is_maximized 
    3392  
    33933431 
    33943432    def display_splash_screen(self, parent, 
     
    34273465        return s_screen 
    34283466 
    3429  
    34303467    def on_close_splash_screen(self, event): 
    34313468        """ 
     
    34473484        """ 
    34483485        # Initialize the Frame object 
    3449         CHILD_FRAME.__init__(self, parent=parent, id=wx.ID_ANY, title=title, size=size) 
     3486        CHILD_FRAME.__init__(self, parent=parent, id=wx.ID_ANY, 
     3487                             title=title, size=size) 
    34503488        self.parent = parent 
    34513489        self.name = "Untitled" 
    34523490        self.batch_on = self.parent.batch_on 
    34533491        self.panel = panel 
    3454         if panel != None: 
     3492        if panel is not None: 
    34553493            self.set_panel(panel) 
    34563494        self.Show(False) 
  • src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py

    r245ae18 r29e872e  
    6565        # context menu 
    6666        self._slicerpop = None 
    67  
    6867        self._available_data = [] 
    6968        self._symbol_labels = self.get_symbol_label() 
     
    732731                self.subplot.set_ylim(y_range) 
    733732                self.subplot.figure.canvas.draw_idle() 
     733                self.is_zoomed = True 
    734734        d.Destroy() 
    735735 
  • src/sas/sasgui/guiframe/dataFitting.py

    r9b6d62d r1fac6c0  
    1717    """ 
    1818    """ 
    19     def __init__(self, x=None, y=None, dx=None, dy=None): 
     19    def __init__(self, x=None, y=None, dx=None, dy=None, lam=None, dlam=None, isSesans=False): 
    2020        """ 
    2121        """ 
     
    2424        if y is None: 
    2525            y = [] 
    26         PlotData1D.__init__(self, x, y, dx, dy) 
    27         LoadData1D.__init__(self, x, y, dx, dy) 
     26        self.isSesans = isSesans 
     27        PlotData1D.__init__(self, x, y, dx, dy, lam, dlam) 
     28        LoadData1D.__init__(self, x, y, dx, dy, lam, dlam, isSesans) 
    2829        self.id = None 
    2930        self.list_group_id = [] 
     
    6869        # First, check the data compatibility 
    6970        dy, dy_other = self._validity_check(other) 
    70         result = Data1D(x=[], y=[], dx=None, dy=None) 
     71        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    7172        result.clone_without_data(length=len(self.x), clone=self) 
    7273        result.copy_from_datainfo(data1d=self) 
     
    115116        # First, check the data compatibility 
    116117        self._validity_check_union(other) 
    117         result = Data1D(x=[], y=[], dx=None, dy=None) 
     118        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=None) 
    118119        tot_length = len(self.x) + len(other.x) 
    119120        result = self.clone_without_data(length=tot_length, clone=result) 
     121        if self.dlam == None or other.dlam is None: 
     122            result.dlam = None 
     123        else: 
     124            result.dlam = numpy.zeros(tot_length) 
    120125        if self.dy == None or other.dy is None: 
    121126            result.dy = None 
     
    141146        result.y = numpy.append(self.y, other.y) 
    142147        result.y = result.y[ind] 
     148        result.lam = numpy.append(self.lam, other.lam) 
     149        result.lam = result.lam[ind] 
     150        if result.dlam != None: 
     151            result.dlam = numpy.append(self.dlam, other.dlam) 
     152            result.dlam = result.dlam[ind] 
    143153        if result.dy != None: 
    144154            result.dy = numpy.append(self.dy, other.dy) 
     
    260270        # First, check the data compatibility 
    261271        self._validity_check_union(other) 
    262         result = Data1D(x=[], y=[], dx=None, dy=None) 
     272        result = Data1D(x=[], y=[], lam=[], dx=None, dy=None, dlam=[]) 
    263273        tot_length = len(self.x)+len(other.x) 
    264274        result.clone_without_data(length=tot_length, clone=self) 
     275        if self.dlam == None or other.dlam is None: 
     276            result.dlam = None 
     277        else: 
     278            result.dlam = numpy.zeros(tot_length) 
    265279        if self.dy == None or other.dy is None: 
    266280            result.dy = None 
     
    285299        result.y = numpy.append(self.y, other.y) 
    286300        result.y = result.y[ind] 
     301        result.lam = numpy.append(self.lam, other.lam) 
     302        result.lam = result.lam[ind] 
    287303        if result.dy != None: 
    288304            result.dy = numpy.append(self.dy, other.dy) 
  • src/sas/sasgui/guiframe/data_manager.py

    rd85c194 r1fac6c0  
    6262        if issubclass(Data2D, data.__class__): 
    6363            new_plot = Data2D(image=None, err_image=None)  
    64         else:  
    65             new_plot = Data1D(x=[], y=[], dx=None, dy=None) 
     64        elif data.meta_data['loader'] == 'SESANS': 
     65            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None, isSesans=True) 
     66        else: 
     67            new_plot = Data1D(x=[], y=[], dx=None, dy=None, lam=None, dlam=None) #SESANS check??? 
    6668            
    6769        new_plot.copy_from_datainfo(data) 
Note: See TracChangeset for help on using the changeset viewer.