Ignore:
Timestamp:
Oct 20, 2016 1:54:06 PM (8 years ago)
Author:
krzywon
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
880e845, cf1910f
Parents:
8b645cc
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/fitting/basepage.py

    r313c5c9 rc8e1996  
    1919 
    2020from sas.sasgui.guiframe.panel_base import PanelBase 
    21 from sas.sasgui.guiframe.utils import format_number, check_float, IdList, check_int 
     21from sas.sasgui.guiframe.utils import format_number, check_float, IdList, \ 
     22    check_int 
    2223from sas.sasgui.guiframe.events import PanelOnFocusEvent 
    2324from sas.sasgui.guiframe.events import StatusEvent 
     
    4243_QMAX_DEFAULT = 0.5 
    4344_NPTS_DEFAULT = 50 
    44 #Control panel width 
     45# Control panel width 
    4546if sys.platform.count("win32") > 0: 
    4647    PANEL_WIDTH = 450 
     
    5758    This class provide general structure of  fitpanel page 
    5859    """ 
    59     ## Internal name for the AUI manager 
     60    # Internal name for the AUI manager 
    6061    window_name = "Fit Page" 
    61     ## Title to appear on top of the window 
     62    # Title to appear on top of the window 
    6263    window_caption = "Fit Page " 
    6364 
     
    7576        PanelBase.__init__(self, parent) 
    7677        self.SetupScrolling() 
    77         #Set window's font size 
     78        # Set window's font size 
    7879        self.SetWindowVariant(variant=FONT_VARIANT) 
    7980        self.SetBackgroundColour(color) 
    8081 
    8182        self._ids = iter(self._id_pool) 
    82         ## parent of the page 
     83        # parent of the page 
    8384        self.parent = parent 
    84         ## manager is the fitting plugin 
    85         ## owner of the page (fitting plugin) 
     85        # manager is the fitting plugin 
     86        # owner of the page (fitting plugin) 
    8687        self.event_owner = None 
    87         ## current model 
     88        # current model 
    8889        self.model = None 
    8990        self.m_name = None 
    9091        self.index_model = None 
    9192        self.panel = None 
    92         ## data 
     93        # data 
    9394        self.data = None 
    94         #list of available data 
     95        # list of available data 
    9596        self.data_list = [] 
    9697        self.mask = None 
    9798        self.uid = wx.NewId() 
    9899        self.graph_id = None 
    99         #Q range for data set 
     100        # Q range for data set 
    100101        self.qmin_data_set = numpy.inf 
    101102        self.qmax_data_set = None 
    102103        self.npts_data_set = 0 
    103         ## Q range 
     104        # Q range 
    104105        self.qmin = None 
    105106        self.qmax = None 
     
    107108        self.qmin_x = _QMIN_DEFAULT 
    108109        self.npts_x = _NPTS_DEFAULT 
    109         ## total number of point: float 
     110        # total number of point: float 
    110111        self.npts = None 
    111112        self.num_points = None 
    112         ## smear default 
     113        # smear default 
    113114        self.current_smearer = None 
    114         ## 2D smear accuracy default 
     115        # 2D smear accuracy default 
    115116        self.smear2d_accuracy = 'Low' 
    116         ## slit smear: 
     117        # slit smear: 
    117118        self.dxl = None 
    118119        self.dxw = None 
    119         ## pinhole smear 
     120        # pinhole smear 
    120121        self.dx_min = None 
    121122        self.dx_max = None 
    122         ##semar attrbs 
     123        # smear attrbs 
    123124        self.enable_smearer = None 
    124125        self.disable_smearer = None 
    125126        self.pinhole_smearer = None 
    126127        self.slit_smearer = None 
    127         ##weigth attrbs 
     128        # weight attrbs 
    128129        self.dI_noweight = None 
    129130        self.dI_didata = None 
    130131        self.dI_sqrdata = None 
    131132        self.dI_idata = None 
    132         ##other attrbs 
     133        # other attrbs 
    133134        self.dq_l = None 
    134135        self.dq_r = None 
     
    149150        self.disp_cb_dict = {} 
    150151 
    151         #self.state = PageState(parent=parent) 
    152         ## dictionary containing list of models 
     152        # self.state = PageState(parent=parent) 
     153        # dictionary containing list of models 
    153154        self.model_list_box = {} 
    154155 
    155         ## Data member to store the dispersion object created 
     156        # Data member to store the dispersion object created 
    156157        self._disp_obj_dict = {} 
    157         ## selected parameters to apply dispersion 
     158        # selected parameters to apply dispersion 
    158159        self.disp_cb_dict = {} 
    159         ## smearer object 
     160        # smearer object 
    160161        self.enable2D = False 
    161162        self._has_magnetic = False 
     
    165166        self.structurebox = None 
    166167        self.categorybox = None 
    167         ##list of model parameters. each item must have same length 
    168         ## each item related to a given parameters 
    169         ##[cb state, name, value, "+/-", error of fit, min, max , units] 
     168        # list of model parameters. each item must have same length 
     169        # each item related to a given parameters 
     170        # [cb state, name, value, "+/-", error of fit, min, max , units] 
    170171        self.parameters = [] 
    171172        # non-fittable parameter whose value is astring 
    172173        self.str_parameters = [] 
    173         ## list of parameters to fit , must be like self.parameters 
     174        # list of parameters to fit , must be like self.parameters 
    174175        self.param_toFit = [] 
    175         ## list of looking like parameters but with non fittable parameters info 
     176        # list of looking like parameters but with non fittable parameters info 
    176177        self.fixed_param = [] 
    177         ## list of looking like parameters but with  fittable parameters info 
     178        # list of looking like parameters but with  fittable parameters info 
    178179        self.fittable_param = [] 
    179         ##list of dispersion parameters 
     180        # list of dispersion parameters 
    180181        self.disp_list = [] 
    181182        self.disp_name = "" 
    182183 
    183         ## list of orientation parameters 
     184        # list of orientation parameters 
    184185        self.orientation_params = [] 
    185186        self.orientation_params_disp = [] 
     
    188189#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
    189190#       it is pointless. 
    190 #        if self.model != None: 
     191#        if self.model is not None: 
    191192#            self.disp_list = self.model.getDispParamList() 
    192193        self.temp_multi_functional = False 
    193         ##enable model 2D draw 
     194        # enable model 2D draw 
    194195        self.enable2D = False 
    195         ## check that the fit range is correct to plot the model again 
     196        # check that the fit range is correct to plot the model again 
    196197        self.fitrange = True 
    197         ## Create memento to save the current state 
     198        # Create memento to save the current state 
    198199        self.state = PageState(parent=self.parent, 
    199200                               model=self.model, data=self.data) 
    200         ## flag to determine if state has change 
     201        # flag to determine if state has change 
    201202        self.state_change = False 
    202         ## save customized array 
     203        # save customized array 
    203204        self.values = {}   # type: Dict[str, List[float, ...]] 
    204205        self.weights = {}   # type: Dict[str, List[float, ...]] 
    205         ## retrieve saved state 
     206        # retrieve saved state 
    206207        self.number_saved_state = 0 
    207         ## dictionary of saved state 
     208        # dictionary of saved state 
    208209        self.saved_states = {} 
    209         ## Create context menu for page 
     210        # Create context menu for page 
    210211        self.popUpMenu = wx.Menu() 
    211212 
     
    220221        self.popUpMenu.AppendSeparator() 
    221222 
    222         ## Default locations 
     223        # Default locations 
    223224        self._default_save_location = os.getcwd() 
    224         ## save initial state on context menu 
    225         #self.onSave(event=None) 
     225        # save initial state on context menu 
     226        # self.onSave(event=None) 
    226227        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    227228 
     
    229230        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) 
    230231 
    231         ## create the basic structure of the panel with empty sizer 
     232        # create the basic structure of the panel with empty sizer 
    232233        self.define_page_structure() 
    233         ## drawing Initial dispersion parameters sizer 
     234        # drawing Initial dispersion parameters sizer 
    234235        self.set_dispers_sizer() 
    235236 
    236         ## layout 
     237        # layout 
    237238        self.set_layout() 
    238239 
     
    260261                    self._create_default_1d_data() 
    261262 
    262             if self.model != None: 
     263            if self.model is not None: 
    263264                if not self.data.is_data: 
    264                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    265                                                                 [self.data]) 
     265                    self._manager.page_finder[self.uid].set_fit_data( 
     266                        data=[self.data]) 
    266267            self.on_smear_helper(update=True) 
    267268            self.state.enable_smearer = self.enable_smearer.GetValue() 
     
    325326        self.data.id = str(self.uid) + " data" 
    326327        self.data.group_id = str(self.uid) + " Model2D" 
    327         ## Default values 
     328        # Default values 
    328329        self.data.detector.append(Detector()) 
    329330        index = len(self.data.detector) - 1 
     
    342343        x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    343344        y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    344         ## use data info instead 
     345        # use data info instead 
    345346        new_x = numpy.tile(x, (len(y), 1)) 
    346347        new_y = numpy.tile(y, (len(x), 1)) 
     
    383384        Update menu1 on cliking the page tap 
    384385        """ 
    385         if self._manager.menu1 != None: 
    386             chain_menu = self._manager.menu1.FindItemById(\ 
     386        if self._manager.menu1 is not None: 
     387            chain_menu = self._manager.menu1.FindItemById( 
    387388                                                   self._manager.id_reset_flag) 
    388389            chain_menu.Enable(self.batch_on) 
    389390            sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit) 
    390391            flag = self.data.is_data\ 
    391                             and (self.model != None) 
     392                            and (self.model is not None) 
    392393            sim_menu.Enable(not self.batch_on and flag) 
    393394            batch_menu = \ 
     
    530531        fill sizer containing dispersity info 
    531532        """ 
    532         #print "==== entering set_dispers_sizer ===" 
     533        # print "==== entering set_dispers_sizer ===" 
    533534        self.sizer4.Clear(True) 
    534535        name = "Polydispersity and Orientational Distribution" 
     
    536537        box_description.SetForegroundColour(wx.BLUE) 
    537538        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    538         #---------------------------------------------------- 
     539        # ---------------------------------------------------- 
    539540        self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 
    540541                                           style=wx.RB_GROUP) 
     
    556557        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    557558                  id=self.enable_disp.GetId()) 
    558         #MAC needs SetValue 
     559        # MAC needs SetValue 
    559560        self.disable_disp.SetValue(True) 
    560561        sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL) 
     
    568569        sizer_dispersion.Add(self.disp_help_bt) 
    569570 
    570         ## fill a sizer for dispersion 
     571        # fill a sizer for dispersion 
    571572        boxsizer1.Add(sizer_dispersion, 0, 
    572573                      wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 
     
    575576 
    576577        boxsizer1.Add(self.sizer4_4) 
    577         #----------------------------------------------------- 
     578        # ----------------------------------------------------- 
    578579        self.sizer4.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    579580        self.sizer4_4.Layout() 
     
    582583 
    583584        self.Refresh() 
    584         ## saving the state of enable dispersity button 
     585        # saving the state of enable dispersity button 
    585586        self.state.enable_disp = self.enable_disp.GetValue() 
    586587        self.state.disable_disp = self.disable_disp.GetValue() 
     
    592593        """ 
    593594        menu = event.GetEventObject() 
    594         ## post help message for the selected model 
     595        # post help message for the selected model 
    595596        msg = menu.GetHelpString(event.GetId()) 
    596597        msg += " reloaded" 
     
    599600        name = menu.GetLabel(event.GetId()) 
    600601        self._on_select_model_helper() 
    601         if self.model != None: 
     602        if self.model is not None: 
    602603            self.m_name = self.model.name 
    603604        if name in self.saved_states.keys(): 
    604605            previous_state = self.saved_states[name] 
    605             ## reset state of checkbox,textcrtl  and  regular parameters value 
     606            # reset state of checkbox,textcrtl  and  regular parameters value 
    606607 
    607608            self.reset_page(previous_state) 
     
    626627        # Ask the user the location of the file to write to. 
    627628        path = None 
    628         if self.parent != None: 
     629        if self.parent is not None: 
    629630            self._default_save_location = \ 
    630631                        self._manager.parent._default_save_location 
     
    636637            self._default_save_location = os.path.dirname(path) 
    637638            self._manager.parent._default_save_location = \ 
    638                                 self._default_save_location 
     639                self._default_save_location 
    639640        else: 
    640641            return None 
     
    643644        # Make sure the ext included in the file name 
    644645        fName = os.path.splitext(path)[0] + extens 
    645         #the manager write the state into file 
     646        # the manager write the state into file 
    646647        self._manager.save_fit_state(filepath=fName, fitstate=new_state) 
    647648        return new_state 
     
    651652        Copy Parameter values to the clipboad 
    652653        """ 
    653         if event != None: 
     654        if event is not None: 
    654655            event.Skip() 
    655656        # It seems MAC needs wxCallAfter 
     
    667668        Paste Parameter values to the panel if possible 
    668669        """ 
    669         #if event != None: 
     670        # if event is not None: 
    670671        #    event.Skip() 
    671672        # It seems MAC needs wxCallAfter for the setvalues 
     
    673674        wx.CallAfter(self.get_paste) 
    674675        # messages depending on the flag 
    675         #self._copy_info(True) 
     676        # self._copy_info(True) 
    676677 
    677678    def _copy_info(self, flag): 
     
    682683        """ 
    683684        # messages depending on the flag 
    684         if flag == None: 
     685        if flag is None: 
    685686            msg = " Parameter values are copied to the clipboard..." 
    686687            infor = 'warning' 
     
    710711        save history of the data and model 
    711712        """ 
    712         if self.model == None: 
     713        if self.model is None: 
    713714            msg = "Can not bookmark; Please select Data and Model first..." 
    714715            wx.MessageBox(msg, 'Info') 
     
    716717        self.save_current_state() 
    717718        new_state = self.state.clone() 
    718         ##Add model state on context menu 
     719        # Add model state on context menu 
    719720        self.number_saved_state += 1 
    720721        current_time, current_date = self._get_time_stamp() 
    721         #name= self.model.name+"[%g]"%self.number_saved_state 
     722        # name= self.model.name+"[%g]"%self.number_saved_state 
    722723        name = "Fitting: %g]" % self.number_saved_state 
    723724        name += self.model.__class__.__name__ 
     
    725726        self.saved_states[name] = new_state 
    726727 
    727         ## Add item in the context menu 
     728        # Add item in the context menu 
    728729        msg = "Model saved at %s on %s" % (current_time, current_date) 
    729         ## post help message for the selected model 
     730        # post help message for the selected model 
    730731        msg += " Saved! right click on this page to retrieve this model" 
    731732        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    761762        """ 
    762763        try: 
    763             if path == None: 
     764            if path is None: 
    764765                status = " Selected Distribution was not loaded: %s" % path 
    765766                wx.PostEvent(self._manager.parent, 
     
    796797        Store current state 
    797798        """ 
    798         ## save model option 
    799         if self.model != None: 
     799        # save model option 
     800        if self.model is not None: 
    800801            self.disp_list = self.model.getDispParamList() 
    801802            self.state.disp_list = copy.deepcopy(self.disp_list) 
    802803            self.state.model = self.model.clone() 
    803804 
    804             #model combobox: complex code because of mac's silent error 
    805             if self.structurebox != None: 
     805            # model combobox: complex code because of mac's silent error 
     806            if self.structurebox is not None: 
    806807                if self.structurebox.IsShown(): 
    807808                    self.state.structurecombobox = 'None' 
    808809                    s_select = self.structurebox.GetSelection() 
    809810                    if s_select > 0: 
    810                         self.state.structurecombobox = self.structurebox.\ 
    811                         GetString(s_select) 
    812             if self.formfactorbox != None: 
     811                        self.state.structurecombobox = \ 
     812                            self.structurebox.GetString(s_select) 
     813            if self.formfactorbox is not None: 
    813814                f_select = self.formfactorbox.GetSelection() 
    814815                if f_select > 0: 
    815                     self.state.formfactorcombobox = self.formfactorbox.\ 
    816                     GetString(f_select) 
    817         if self.categorybox != None: 
     816                    self.state.formfactorcombobox = \ 
     817                        self.formfactorbox.GetString(f_select) 
     818        if self.categorybox is not None: 
    818819            cb_select = self.categorybox.GetSelection() 
    819820            if cb_select > 0: 
    820                 self.state.categorycombobox = self.categorybox.\ 
    821                 GetString(cb_select) 
     821                self.state.categorycombobox = \ 
     822                    self.categorybox.GetString(cb_select) 
    822823 
    823824        self.state.enable2D = copy.deepcopy(self.enable2D) 
    824825        self.state.values = copy.deepcopy(self.values) 
    825826        self.state.weights = copy.deepcopy(self.weights) 
    826         ## save data 
     827        # save data 
    827828        self.state.data = copy.deepcopy(self.data) 
    828829        self.state.qmax_x = self.qmax_x 
     
    859860            self.state.values = copy.deepcopy(self.values) 
    860861            self.state.weights = copy.deepcopy(self.weights) 
    861         ## save plotting range 
     862        # save plotting range 
    862863        self._save_plotting_range() 
    863864 
     
    869870        self.state.str_parameters = [] 
    870871 
    871         ## save checkbutton state and txtcrtl values 
     872        # save checkbutton state and txtcrtl values 
    872873        self._copy_parameters_state(self.str_parameters, 
    873874                                    self.state.str_parameters) 
     
    881882                                    self.state.fittable_param) 
    882883        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    883         #save chisqr 
     884        # save chisqr 
    884885        self.state.tcChi = self.tcChi.GetValue() 
    885886 
     
    888889        Store current state for fit_page 
    889890        """ 
    890         ## save model option 
    891         if self.model != None: 
     891        # save model option 
     892        if self.model is not None: 
    892893            self.disp_list = self.model.getDispParamList() 
    893894            self.state.disp_list = copy.deepcopy(self.disp_list) 
     
    897898        self.state.values = copy.deepcopy(self.values) 
    898899        self.state.weights = copy.deepcopy(self.weights) 
    899         ## save data 
     900        # save data 
    900901        self.state.data = copy.deepcopy(self.data) 
    901902 
     
    918919        self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 
    919920        self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 
    920         if hasattr(self, "disp_box") and self.disp_box != None: 
     921        if hasattr(self, "disp_box") and self.disp_box is not None: 
    921922            self.state.disp_box = self.disp_box.GetCurrentSelection() 
    922923 
    923924            if len(self.disp_cb_dict) > 0: 
    924925                for k, v in self.disp_cb_dict.iteritems(): 
    925                     if v == None: 
     926                    if v is None: 
    926927                        self.state.disp_cb_dict[k] = v 
    927928                    else: 
     
    937938            self.state.weights = copy.deepcopy(self.weights) 
    938939 
    939         ## save plotting range 
     940        # save plotting range 
    940941        self._save_plotting_range() 
    941942 
    942         ## save checkbutton state and txtcrtl values 
     943        # save checkbutton state and txtcrtl values 
    943944        self._copy_parameters_state(self.orientation_params, 
    944945                                    self.state.orientation_params) 
     
    959960            msg = "Please load Data and select Model to start..." 
    960961            wx.MessageBox(msg, 'Info') 
    961             return  True 
     962            return True 
    962963 
    963964    def set_model_state(self, state): 
     
    968969        self.disp_list = state.disp_list 
    969970 
    970         ## fill model combobox 
     971        # fill model combobox 
    971972        self._show_combox_helper() 
    972         #select the current model 
     973        # select the current model 
    973974        try: 
    974975            # to support older version 
     
    10091010        self.structurebox.SetSelection(structfactor_pos) 
    10101011 
    1011         if state.multi_factor != None: 
     1012        if state.multi_factor is not None: 
    10121013            self.multifactorbox.SetSelection(state.multi_factor) 
    10131014 
    1014         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1015        # reset state of checkbox,textcrtl  and  regular parameters value 
    10151016        self._reset_parameters_state(self.orientation_params_disp, 
    10161017                                     state.orientation_params_disp) 
     
    10201021                                     state.str_parameters) 
    10211022        self._reset_parameters_state(self.parameters, state.parameters) 
    1022         ## display dispersion info layer 
     1023        # display dispersion info layer 
    10231024        self.enable_disp.SetValue(state.enable_disp) 
    10241025        self.disable_disp.SetValue(state.disable_disp) 
    10251026 
    1026         if hasattr(self, "disp_box") and self.disp_box != None: 
     1027        if hasattr(self, "disp_box") and self.disp_box is not None: 
    10271028            self.disp_box.SetSelection(state.disp_box) 
    10281029            n = self.disp_box.GetCurrentSelection() 
     
    10361037 
    10371038                    if hasattr(self.disp_cb_dict[item], "SetValue"): 
    1038                         self.disp_cb_dict[item].SetValue(\ 
     1039                        self.disp_cb_dict[item].SetValue( 
    10391040                                                    state.disp_cb_dict[item]) 
    10401041                        # Create the dispersion objects 
    10411042                        disp_model = POLYDISPERSITY_MODELS['array']() 
    10421043                        if hasattr(state, "values") and \ 
    1043                                  self.disp_cb_dict[item].GetValue() == True: 
     1044                                 self.disp_cb_dict[item].GetValue() is True: 
    10441045                            if len(state.values) > 0: 
    10451046                                self.values = state.values 
     
    10521053                        self._disp_obj_dict[item] = disp_model 
    10531054                        # Set the new model as the dispersion object 
    1054                         #for the selected parameter 
     1055                        # for the selected parameter 
    10551056                        self.model.set_dispersion(item, disp_model) 
    10561057 
     
    10621063                for item in keys: 
    10631064                    if item in self.disp_list and \ 
    1064                         not item in self.model.details: 
     1065                            item not in self.model.details: 
    10651066                        self.model.details[item] = ["", None, None] 
    10661067                self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    10671068                self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    1068         ## smearing info  restore 
     1069        # smearing info  restore 
    10691070        if hasattr(self, "enable_smearer"): 
    1070             ## set smearing value whether or not the data 
    1071             #contain the smearing info 
     1071            # set smearing value whether or not the data 
     1072            # contain the smearing info 
    10721073            self.enable_smearer.SetValue(state.enable_smearer) 
    10731074            self.disable_smearer.SetValue(state.disable_smearer) 
     
    10811082        self.dI_idata.SetValue(state.dI_idata) 
    10821083 
    1083         ## we have two more options for smearing 
     1084        # we have two more options for smearing 
    10841085        if self.pinhole_smearer.GetValue(): 
    10851086            self.onPinholeSmear(event=None) 
     
    10871088            self.onSlitSmear(event=None) 
    10881089 
    1089         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1090        # reset state of checkbox,textcrtl  and dispersity parameters value 
    10901091        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    10911092        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    10921093 
    1093         ## draw the model with previous parameters value 
     1094        # draw the model with previous parameters value 
    10941095        self._onparamEnter_helper() 
    10951096        self.select_param(event=None) 
    1096         #Save state_fit 
     1097        # Save state_fit 
    10971098        self.save_current_state_fit() 
    10981099        self._lay_out() 
     
    11081109                if state.formfactorcombobox in list_item: 
    11091110                    return self.categorybox.Items.index(key) 
     1111        return 0 
    11101112 
    11111113    def reset_page_helper(self, state): 
     
    11181120            state of the graphic interface 
    11191121        """ 
    1120         if state == None: 
     1122        if state is None: 
    11211123            return 
    11221124        # set data, etc. from the state 
     
    11241126        data = state.data 
    11251127 
    1126         if data == None: 
     1128        if data is None: 
    11271129            data_min = state.qmin 
    11281130            data_max = state.qmax 
     
    11481150        self.disp_list = state.disp_list 
    11491151 
    1150         ## fill model combobox 
     1152        # fill model combobox 
    11511153        self._show_combox_helper() 
    1152         #select the current model 
     1154        # select the current model 
    11531155        try: 
    11541156            # to support older version 
    11551157            category_pos = int(state.categorycombobox) 
    11561158        except: 
    1157             state.formfactorcombobox = unicode(state.formfactorcombobox.lower()) 
     1159            state.formfactorcombobox = state.formfactorcombobox.lower() 
     1160            state.formfactorcombobox = \ 
     1161                state.formfactorcombobox.replace('model', '') 
     1162            state.formfactorcombobox = unicode(state.formfactorcombobox) 
    11581163            state.categorycombobox = unicode(state.categorycombobox) 
    1159             category_pos = 0 
    11601164            if state.categorycombobox in self.categorybox.Items: 
    11611165                category_pos = self.categorybox.Items.index( 
     
    11801184        self.formfactorbox.Select(formfactor_pos) 
    11811185 
     1186        structfactor_pos = 0 
    11821187        try: 
    11831188            # to support older version 
     
    11851190        except: 
    11861191            if state.structurecombobox is not None: 
    1187                 structfactor_pos = 0 
    11881192                state.structurecombobox = unicode(state.structurecombobox) 
    11891193                for ind_struct in range(self.structurebox.GetCount()): 
    11901194                    if self.structurebox.GetString(ind_struct) == \ 
    1191                                                         (state.structurecombobox): 
     1195                                                    (state.structurecombobox): 
    11921196                        structfactor_pos = int(ind_struct) 
    11931197                        break 
     
    11951199        self.structurebox.SetSelection(structfactor_pos) 
    11961200 
    1197         if state.multi_factor != None: 
     1201        if state.multi_factor is not None: 
    11981202            self.multifactorbox.SetSelection(state.multi_factor) 
    11991203 
    1200         #draw the panel according to the new model parameter 
     1204        # draw the panel according to the new model parameter 
    12011205        self._on_select_model(event=None) 
    12021206 
    12031207        # take care of 2D button 
    1204         if data == None and self.model_view.IsEnabled(): 
     1208        if data is None and self.model_view.IsEnabled(): 
    12051209            if self.enable2D: 
    12061210                self.model_view.SetLabel("2D Mode") 
     
    12081212                self.model_view.SetLabel("1D Mode") 
    12091213 
    1210         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1214        # reset state of checkbox,textcrtl  and  regular parameters value 
    12111215        self._reset_parameters_state(self.orientation_params_disp, 
    12121216                                     state.orientation_params_disp) 
     
    12161220                                     state.str_parameters) 
    12171221        self._reset_parameters_state(self.parameters, state.parameters) 
    1218         ## display dispersion info layer 
     1222        # display dispersion info layer 
    12191223        self.enable_disp.SetValue(state.enable_disp) 
    12201224        self.disable_disp.SetValue(state.disable_disp) 
     
    12241228            self._set_dipers_Param(event=None) 
    12251229            self._reset_page_disp_helper(state) 
    1226         ##plotting range restore 
     1230        # plotting range restore 
    12271231        self._reset_plotting_range(state) 
    1228         ## smearing info  restore 
     1232        # smearing info  restore 
    12291233        if hasattr(self, "enable_smearer"): 
    1230             ## set smearing value whether or not the data 
    1231             #contain the smearing info 
     1234            # set smearing value whether or not the data 
     1235            # contain the smearing info 
    12321236            self.enable_smearer.SetValue(state.enable_smearer) 
    12331237            self.disable_smearer.SetValue(state.disable_smearer) 
     
    12471251            self.dI_idata.SetValue(False) 
    12481252 
    1249         ## we have two more options for smearing 
     1253        # we have two more options for smearing 
    12501254        if self.pinhole_smearer.GetValue(): 
    12511255            self.dx_min = state.dx_min 
    12521256            self.dx_max = state.dx_max 
    1253             if self.dx_min != None: 
     1257            if self.dx_min is not None: 
    12541258                self.smear_pinhole_min.SetValue(str(self.dx_min)) 
    1255             if self.dx_max != None: 
     1259            if self.dx_max is not None: 
    12561260                self.smear_pinhole_max.SetValue(str(self.dx_max)) 
    12571261            self.onPinholeSmear(event=None) 
     
    12591263            self.dxl = state.dxl 
    12601264            self.dxw = state.dxw 
    1261             if self.dxl != None: 
     1265            if self.dxl is not None: 
    12621266                self.smear_slit_height.SetValue(str(self.dxl)) 
    1263             if self.dxw != None: 
     1267            if self.dxw is not None: 
    12641268                self.smear_slit_width.SetValue(str(self.dxw)) 
    12651269            else: 
     
    12671271            self.onSlitSmear(event=None) 
    12681272 
    1269         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1273        # reset state of checkbox,textcrtl  and dispersity parameters value 
    12701274        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    12711275        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    12721276 
    1273         ## draw the model with previous parameters value 
     1277        # draw the model with previous parameters value 
    12741278        self._onparamEnter_helper() 
    1275         #reset the value of chisqr when not consistent with the value computed 
     1279        # reset the value of chisqr when not consistent with the value computed 
    12761280        self.tcChi.SetValue(str(self.state.tcChi)) 
    1277         ## reset context menu items 
     1281        # reset context menu items 
    12781282        self._reset_context_menu() 
    12791283 
    1280         ## set the value of the current state to the state given as parameter 
     1284        # set the value of the current state to the state given as parameter 
    12811285        self.state = state.clone() 
    12821286        self.state.m_name = self.m_name 
     
    12891293        for item in keys: 
    12901294            if item in self.disp_list and \ 
    1291                 not item in self.model.details: 
     1295                            item not in self.model.details: 
    12921296                self.model.details[item] = ["", None, None] 
    1293         #for k,v in self.state.disp_cb_dict.iteritems(): 
     1297        # for k,v in self.state.disp_cb_dict.iteritems(): 
    12941298        self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    12951299        self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
     
    12981302 
    12991303        for key, disp_type in state._disp_obj_dict.iteritems(): 
    1300             #disp_model = disp 
     1304            # disp_model = disp 
    13011305            disp_model = POLYDISPERSITY_MODELS[disp_type]() 
    13021306            self._disp_obj_dict[key] = disp_model 
     
    13071311                self.model.set_dispersion(param_name, disp_model) 
    13081312                self.model._persistency_dict[key] = \ 
    1309                                  [state.values, state.weights] 
     1313                    [state.values, state.weights] 
    13101314            except Exception: 
    13111315                logging.error(traceback.format_exc()) 
    13121316            selection = self._find_polyfunc_selection(disp_model) 
    13131317            for list in self.fittable_param: 
    1314                 if list[1] == key and list[7] != None: 
     1318                if list[1] == key and list[7] is not None: 
    13151319                    list[7].SetSelection(selection) 
    13161320                    # For the array disp_model, set the values and weights 
     
    13411345        open a dialog file to selected the customized dispersity 
    13421346        """ 
    1343         if self.parent != None: 
     1347        if self.parent is not None: 
    13441348            self._default_save_location = \ 
    13451349                        self._manager.parent.get_save_location() 
     
    13601364        for name, _ in self.state.saved_states.iteritems(): 
    13611365            self.number_saved_state += 1 
    1362             ## Add item in the context menu 
     1366            # Add item in the context menu 
    13631367            wx_id = ids.next() 
    13641368            msg = 'Save model and state %g' % self.number_saved_state 
     
    13771381        save radiobutton containing the type model that can be selected 
    13781382        """ 
    1379         #self.state.shape_rbutton = self.shape_rbutton.GetValue() 
    1380         #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
    1381         #self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    1382         #self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
     1383        # self.state.shape_rbutton = self.shape_rbutton.GetValue() 
     1384        # self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
     1385        # self.state.struct_rbutton = self.struct_rbutton.GetValue() 
     1386        # self.state.plugin_rbutton = self.plugin_rbutton.GetValue() 
    13831387        self.state.structurecombobox = self.structurebox.GetLabel() 
    13841388        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    13851389        self.state.categorycombobox = self.categorybox.GetLabel() 
    13861390 
    1387         ## post state to fit panel 
     1391        # post state to fit panel 
    13881392        event = PageInfoEvent(page=self) 
    13891393        wx.PostEvent(self.parent, event) 
     
    13971401        self.state.npts = self.npts_x 
    13981402 
    1399     def _onparamEnter_helper(self,is_modified = False): 
     1403    def _onparamEnter_helper(self, is_modified=False): 
    14001404        """ 
    14011405        check if values entered by the user are changed and valid to replot 
     
    14031407        """ 
    14041408        # Flag to register when a parameter has changed. 
    1405         #is_modified = False 
     1409        # is_modified = False 
    14061410        self.fitrange = True 
    14071411        is_2Ddata = False 
    1408         #self._undo.Enable(True) 
     1412        # self._undo.Enable(True) 
    14091413        # check if 2d data 
    14101414        if self.data.__class__.__name__ == "Data2D": 
    14111415            is_2Ddata = True 
    1412         if self.model != None: 
    1413             #Either we get a is_modified = True passed in because 
    1414             #_update_paramv_on_fit() has been called already or 
     1416        if self.model is not None: 
     1417            # Either we get a is_modified = True passed in because 
     1418            # _update_paramv_on_fit() has been called already or 
    14151419            # we need to check here ourselves. 
    14161420            if not is_modified: 
     
    14391443                self.fitrange = False 
    14401444 
    1441             ## if any value is modify draw model with new value 
     1445            # if any value is modify draw model with new value 
    14421446            if not self.fitrange: 
    1443                 #self.btFit.Disable() 
     1447                # self.btFit.Disable() 
    14441448                if is_2Ddata: 
    14451449                    self.btEditMask.Disable() 
     
    14551459                self.Refresh() 
    14561460 
    1457         #logging.info("is_modified flag set to %g",is_modified) 
     1461        # logging.info("is_modified flag set to %g",is_modified) 
    14581462        return is_modified 
    14591463 
     
    14621466        make sure that update param values just before the fitting 
    14631467        """ 
    1464         #flag for qmin qmax check values 
     1468        # flag for qmin qmax check values 
    14651469        flag = True 
    14661470        self.fitrange = True 
    14671471        is_modified = False 
    14681472 
    1469         #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
    1470         #updating ... ",type="update")) 
    1471  
    1472         ##So make sure that update param values on_Fit. 
    1473         #self._undo.Enable(True) 
    1474         if self.model != None: 
     1473        # wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
     1474        # updating ... ",type="update")) 
     1475 
     1476        # So make sure that update param values on_Fit. 
     1477        # self._undo.Enable(True) 
     1478        if self.model is not None: 
    14751479            if self.Npts_total.GetValue() != self.Npts_fit.GetValue(): 
    14761480                if not self.data.is_data: 
    1477                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    1478                                                                 [self.data]) 
    1479             ##Check the values 
     1481                    self._manager.page_finder[self.uid].set_fit_data( 
     1482                        data=[self.data]) 
     1483            # Check the values 
    14801484            is_modified = (self._check_value_enter(self.fittable_param) 
    1481                             or self._check_value_enter(self.fixed_param) 
    1482                             or self._check_value_enter(self.parameters)) 
     1485                           or self._check_value_enter(self.fixed_param) 
     1486                           or self._check_value_enter(self.parameters)) 
    14831487 
    14841488            # If qmin and qmax have been modified, update qmin and qmax and 
     
    15211525                                              enable_smearer=enable_smearer, 
    15221526                                              draw=False) 
    1523                     if self.data != None: 
    1524                         index_data = ((self.qmin_x <= self.data.x) & \ 
     1527                    if self.data is not None: 
     1528                        index_data = ((self.qmin_x <= self.data.x) & 
    15251529                                      (self.data.x <= self.qmax_x)) 
    1526                         val = str(len(self.data.x[index_data == True])) 
     1530                        val = str(len(self.data.x[index_data is True])) 
    15271531                        self.Npts_fit.SetValue(val) 
    15281532                    else: 
     
    15441548            flag = False 
    15451549 
    1546         #For invalid q range, disable the mask editor and fit button, vs. 
     1550        # For invalid q range, disable the mask editor and fit button, vs. 
    15471551        if not self.fitrange: 
    15481552            if self._is_2D(): 
    15491553                self.btEditMask.Disable() 
    15501554        else: 
    1551             if self._is_2D() and  self.data.is_data and not self.batch_on: 
     1555            if self._is_2D() and self.data.is_data and not self.batch_on: 
    15521556                self.btEditMask.Enable(True) 
    15531557 
     
    15621566            logging.error(traceback.format_exc()) 
    15631567 
    1564         return flag,is_modified 
     1568        return flag, is_modified 
    15651569 
    15661570    def _reset_parameters_state(self, listtorestore, statelist): 
     
    15761580            item_page = listtorestore[j] 
    15771581            item_page_info = statelist[j] 
    1578             ##change the state of the check box for simple parameters 
    1579             if item_page[0] != None: 
     1582            # change the state of the check box for simple parameters 
     1583            if item_page[0] is not None: 
    15801584                item_page[0].SetValue(item_page_info[0]) 
    1581             if item_page[2] != None: 
     1585            if item_page[2] is not None: 
    15821586                item_page[2].SetValue(item_page_info[2]) 
    15831587                if item_page[2].__class__.__name__ == "ComboBox": 
     
    15851589                        fun_val = self.model.fun_list[item_page_info[2]] 
    15861590                        self.model.setParam(item_page_info[1], fun_val) 
    1587             if item_page[3] != None: 
    1588                 ## show or hide text +/- 
     1591            if item_page[3] is not None: 
     1592                # show or hide text +/- 
    15891593                if item_page_info[2]: 
    15901594                    item_page[3].Show(True) 
    15911595                else: 
    15921596                    item_page[3].Hide() 
    1593             if item_page[4] != None: 
    1594                 ## show of hide the text crtl for fitting error 
     1597            if item_page[4] is not None: 
     1598                # show of hide the text crtl for fitting error 
    15951599                if item_page_info[4][0]: 
    15961600                    item_page[4].Show(True) 
     
    15981602                else: 
    15991603                    item_page[3].Hide() 
    1600             if item_page[5] != None: 
    1601                 ## show of hide the text crtl for fitting error 
     1604            if item_page[5] is not None: 
     1605                # show of hide the text crtl for fitting error 
    16021606                item_page[5].Show(item_page_info[5][0]) 
    16031607                item_page[5].SetValue(item_page_info[5][1]) 
    16041608 
    1605             if item_page[6] != None: 
    1606                 ## show of hide the text crtl for fitting error 
     1609            if item_page[6] is not None: 
     1610                # show of hide the text crtl for fitting error 
    16071611                item_page[6].Show(item_page_info[6][0]) 
    16081612                item_page[6].SetValue(item_page_info[6][1]) 
     
    16201624            item_page = listtorestore[j] 
    16211625            item_page_info = statelist[j] 
    1622             ##change the state of the check box for simple parameters 
    1623  
    1624             if item_page[0] != None: 
     1626            # change the state of the check box for simple parameters 
     1627 
     1628            if item_page[0] is not None: 
    16251629                item_page[0].SetValue(format_number(item_page_info[0], True)) 
    16261630 
    1627             if item_page[2] != None: 
     1631            if item_page[2] is not None: 
    16281632                param_name = item_page_info[1] 
    16291633                value = item_page_info[2] 
     
    16481652 
    16491653            checkbox_state = None 
    1650             if item[0] != None: 
     1654            if item[0] is not None: 
    16511655                checkbox_state = item[0].GetValue() 
    16521656            parameter_name = item[1] 
    16531657            parameter_value = None 
    1654             if item[2] != None: 
     1658            if item[2] is not None: 
    16551659                parameter_value = item[2].GetValue() 
    16561660            static_text = None 
    1657             if item[3] != None: 
     1661            if item[3] is not None: 
    16581662                static_text = item[3].IsShown() 
    16591663            error_value = None 
    16601664            error_state = None 
    1661             if item[4] != None: 
     1665            if item[4] is not None: 
    16621666                error_value = item[4].GetValue() 
    16631667                error_state = item[4].IsShown() 
     
    16651669            min_value = None 
    16661670            min_state = None 
    1667             if item[5] != None: 
     1671            if item[5] is not None: 
    16681672                min_value = item[5].GetValue() 
    16691673                min_state = item[5].IsShown() 
     
    16711675            max_value = None 
    16721676            max_state = None 
    1673             if item[6] != None: 
     1677            if item[6] is not None: 
    16741678                max_value = item[6].GetValue() 
    16751679                max_state = item[6].IsShown() 
    16761680            unit = None 
    1677             if item[7] != None: 
     1681            if item[7] is not None: 
    16781682                unit = item[7].GetLabel() 
    16791683 
     
    16831687                              [max_state, max_value], unit]) 
    16841688 
    1685  
    16861689    def _draw_model(self, update_chisqr=True, source='model'): 
    16871690        """ 
     
    17021705        :param chisqr: update chisqr value [bool] 
    17031706        """ 
    1704         #if self.check_invalid_panel(): 
     1707        # if self.check_invalid_panel(): 
    17051708        #    return 
    1706         if self.model != None: 
     1709        if self.model is not None: 
    17071710            temp_smear = None 
    17081711            if hasattr(self, "enable_smearer"): 
     
    17161719            is_2d = self._is_2D() 
    17171720            self._manager.draw_model(self.model, 
    1718                                     data=self.data, 
    1719                                     smearer=temp_smear, 
    1720                                     qmin=float(self.qmin_x), 
    1721                                     qmax=float(self.qmax_x), 
    1722                                     page_id=self.uid, 
    1723                                     toggle_mode_on=toggle_mode_on, 
    1724                                     state=self.state, 
    1725                                     enable2D=is_2d, 
    1726                                     update_chisqr=update_chisqr, 
    1727                                     source='model', 
    1728                                     weight=weight) 
     1721                                     data=self.data, 
     1722                                     smearer=temp_smear, 
     1723                                     qmin=float(self.qmin_x), 
     1724                                     qmax=float(self.qmax_x), 
     1725                                     page_id=self.uid, 
     1726                                     toggle_mode_on=toggle_mode_on, 
     1727                                     state=self.state, 
     1728                                     enable2D=is_2d, 
     1729                                     update_chisqr=update_chisqr, 
     1730                                     source='model', 
     1731                                     weight=weight) 
    17291732 
    17301733    def _on_show_sld(self, event=None): 
     
    17361739 
    17371740        from sas.sasgui.plottools import Data1D as pf_data1d 
    1738         #from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
     1741        # from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
    17391742        from sas.sasgui.guiframe.local_perspectives.plotting.profile_dialog \ 
    1740         import SLDPanel 
     1743            import SLDPanel 
    17411744        sld_data = pf_data1d(x, y) 
    17421745        sld_data.name = 'SLD' 
     
    17911794        self.structurebox.Disable() 
    17921795        self.formfactorbox.Clear() 
    1793         if mod_cat == None: 
     1796        if mod_cat is None: 
    17941797            return 
    17951798        m_list = [] 
     
    18531856        """ 
    18541857        tcrtl = event.GetEventObject() 
    1855         #Clear msg if previously shown. 
     1858        # Clear msg if previously shown. 
    18561859        msg = "" 
    18571860        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    18721875                    tcrtl.SetBackgroundColour("pink") 
    18731876                    msg = "Model Error: wrong value entered: %s" % \ 
    1874                                     sys.exc_info()[1] 
     1877                          sys.exc_info()[1] 
    18751878                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    18761879                    return 
     
    18801883                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    18811884                return 
    1882             #Check if # of points for theory model are valid(>0). 
    1883             if self.npts != None: 
     1885            # Check if # of points for theory model are valid(>0). 
     1886            if self.npts is not None: 
    18841887                if check_float(self.npts): 
    18851888                    temp_npts = float(self.npts.GetValue()) 
     
    18971900        wx.PostEvent(self.parent, event) 
    18981901        self.state_change = False 
    1899         #Draw the model for a different range 
     1902        # Draw the model for a different range 
    19001903        if not self.data.is_data: 
    19011904            self.create_default_data() 
     
    19081911 
    19091912        tcrtl = event.GetEventObject() 
    1910         #Clear msg if previously shown. 
     1913        # Clear msg if previously shown. 
    19111914        msg = "" 
    19121915        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    19291932                    tcrtl.SetBackgroundColour("pink") 
    19301933                    msg = "Model Error: wrong value entered: %s" % \ 
    1931                                         sys.exc_info()[1] 
     1934                          sys.exc_info()[1] 
    19321935                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19331936                    return 
     
    19371940                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19381941                return 
    1939             #Check if # of points for theory model are valid(>0). 
     1942            # Check if # of points for theory model are valid(>0). 
    19401943            if self.Npts_total.IsEditable(): 
    19411944                if check_float(self.Npts_total): 
     
    19551958        wx.PostEvent(self.parent, event) 
    19561959        self.state_change = False 
    1957         #Draw the model for a different range 
     1960        # Draw the model for a different range 
    19581961        self.create_default_data() 
    19591962        self._draw_model() 
     
    19631966        call back for model selection 
    19641967        """ 
    1965         ## reset dictionary containing reference to dispersion 
     1968        # reset dictionary containing reference to dispersion 
    19661969        self._disp_obj_dict = {} 
    19671970        self.disp_cb_dict = {} 
    19681971        self.temp_multi_functional = False 
    19691972        f_id = self.formfactorbox.GetCurrentSelection() 
    1970         #For MAC 
     1973        # For MAC 
    19711974        form_factor = None 
    19721975        if f_id >= 0: 
     
    19751978        if form_factor is None or \ 
    19761979            not hasattr(form_factor, 'is_form_factor') or \ 
    1977             not form_factor.is_form_factor: 
     1980                not form_factor.is_form_factor: 
    19781981            self.structurebox.Hide() 
    19791982            self.text2.Hide() 
     
    19871990            self.text2.Enable() 
    19881991 
    1989         if form_factor != None: 
     1992        if form_factor is not None: 
    19901993            # set multifactor for Mutifunctional models 
    19911994            if form_factor.is_multiplicity_model: 
     
    19951998                self._set_multfactor_combobox(multiplicity) 
    19961999                self._show_multfactor_combobox() 
    1997                 #ToDo: this info should be called directly from the model 
     2000                # ToDo: this info should be called directly from the model 
    19982001                text = form_factor.multiplicity_info[1]  # 'No. of Shells: ' 
    19992002 
     
    20042007 
    20052008                self.multi_factor = self.multifactorbox.GetClientData(m_id) 
    2006                 if self.multi_factor == None: 
     2009                if self.multi_factor is None: 
    20072010                    self.multi_factor = 0 
    20082011                self.multifactorbox.SetSelection(m_id) 
     
    20102013                text = '' 
    20112014                if form_factor.multiplicity_info[0] == \ 
    2012                                         len(form_factor.multiplicity_info[2]): 
     2015                        len(form_factor.multiplicity_info[2]): 
    20132016                    text = form_factor.multiplicity_info[2][self.multi_factor] 
    20142017                self.mutifactor_text1.SetLabel(text) 
     
    20312034        struct_factor = self.structurebox.GetClientData(s_id) 
    20322035 
    2033         if  struct_factor != None: 
     2036        if struct_factor is not None: 
    20342037            from sasmodels.sasview_model import MultiplicationModel 
    20352038            self.model = MultiplicationModel(form_factor(self.multi_factor), 
     
    20382041            if len(form_factor.non_fittable) > 0: 
    20392042                self.temp_multi_functional = True 
    2040         elif form_factor != None: 
     2043        elif form_factor is not None: 
    20412044            if self.multi_factor is not None: 
    20422045                self.model = form_factor(self.multi_factor) 
     
    20532056        else: 
    20542057            self._has_magnetic = False 
    2055         ## post state to fit panel 
     2058        # post state to fit panel 
    20562059        self.state.parameters = [] 
    20572060        self.state.model = self.model 
     
    20632066        self.Layout() 
    20642067 
    2065  
    20662068    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    20672069        """ 
     
    20832085            qmax = float(qmax_ctrl.GetValue()) 
    20842086            if qmin < qmax: 
    2085                 #Make sure to set both colours white. 
     2087                # Make sure to set both colours white. 
    20862088                qmin_ctrl.SetBackgroundColour(wx.WHITE) 
    20872089                qmin_ctrl.Refresh() 
     
    21032105        If valid, setvalues Npts_fit otherwise post msg. 
    21042106        """ 
    2105         #default flag 
     2107        # default flag 
    21062108        flag = True 
    21072109        # Theory 
    2108         if self.data == None and self.enable2D: 
     2110        if self.data is None and self.enable2D: 
    21092111            return flag 
    21102112        for data in self.data_list: 
     
    21122114            radius = numpy.sqrt(data.qx_data * data.qx_data + 
    21132115                                data.qy_data * data.qy_data) 
    2114             #get unmasked index 
     2116            # get unmasked index 
    21152117            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2116                             (radius <= float(self.qmax.GetValue())) 
     2118                         (radius <= float(self.qmax.GetValue())) 
    21172119            index_data = (index_data) & (data.mask) 
    21182120            index_data = (index_data) & (numpy.isfinite(data.data)) 
     
    21302132                flag = False 
    21312133            else: 
    2132                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2134                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21332135                self.fitrange = True 
    21342136 
     
    21402142        If valid, setvalues Npts_fit otherwise post msg. 
    21412143        """ 
    2142         #default flag 
     2144        # default flag 
    21432145        flag = True 
    21442146        # Theory 
    2145         if self.data == None: 
     2147        if self.data is None: 
    21462148            return flag 
    21472149        for data in self.data_list: 
    21482150            # q value from qx and qy 
    21492151            radius = data.x 
    2150             #get unmasked index 
     2152            # get unmasked index 
    21512153            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2152                             (radius <= float(self.qmax.GetValue())) 
     2154                         (radius <= float(self.qmax.GetValue())) 
    21532155            index_data = (index_data) & (numpy.isfinite(data.y)) 
    21542156 
     
    21652167                flag = False 
    21662168            else: 
    2167                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2169                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21682170                self.fitrange = True 
    21692171 
     
    21852187        is_modified = False 
    21862188        for item in list: 
    2187             #skip angle parameters for 1D 
     2189            # skip angle parameters for 1D 
    21882190            if not self.enable2D and item in self.orientation_params: 
    21892191                continue 
     
    22302232                    max_ctrl.SetBackgroundColour("pink") 
    22312233                    max_ctrl.Refresh() 
    2232                     #msg = "Invalid fit range for %s: min must be smaller than max"%name 
    2233                     #wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     2234                    # msg = "Invalid fit range for %s: min must be smaller 
     2235                    # than max"%name 
     2236                    # wx.PostEvent(self._manager.parent, 
     2237                    # StatusEvent(status=msg)) 
    22342238                    continue 
    22352239 
     
    22492253                    # The configuration has changed but it won't change the 
    22502254                    # computed curve so no need to set is_modified to True 
    2251                     #is_modified = True 
     2255                    # is_modified = True 
    22522256                    self.model.details[name][1:3] = low, high 
    22532257 
     
    22672271        Redraw the model with the default dispersity (Gaussian) 
    22682272        """ 
    2269         ## On selction if no model exists. 
    2270         if self.model == None: 
     2273        # On selction if no model exists. 
     2274        if self.model is None: 
    22712275            self.disable_disp.SetValue(True) 
    22722276            msg = "Please select a Model first..." 
     
    22782282        self._reset_dispersity() 
    22792283 
    2280         if self.model == None: 
     2284        if self.model is None: 
    22812285            self.model_disp.Hide() 
    22822286            self.sizer4_4.Clear(True) 
     
    22842288 
    22852289        if self.enable_disp.GetValue(): 
    2286             ## layout for model containing no dispersity parameters 
     2290            # layout for model containing no dispersity parameters 
    22872291 
    22882292            self.disp_list = self.model.getDispParamList() 
     
    22912295                self._layout_sizer_noDipers() 
    22922296            else: 
    2293                 ## set gaussian sizer 
     2297                # set gaussian sizer 
    22942298                self._on_select_Disp(event=None) 
    22952299        else: 
    22962300            self.sizer4_4.Clear(True) 
    22972301 
    2298         ## post state to fit panel 
     2302        # post state to fit panel 
    22992303        self.save_current_state() 
    2300         if event != None: 
     2304        if event is not None: 
    23012305            event = PageInfoEvent(page=self) 
    23022306            wx.PostEvent(self.parent, event) 
    2303         #draw the model with the current dispersity 
    2304  
    2305         #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
    2306         #By comenting it we save an extra Iq calculation 
    2307         #self._draw_model() 
    2308  
    2309         ## Need to use FitInside again here to replace the next four lines. 
    2310         ## Otherwised polydispersity off does not resize the scrollwindow. 
    2311         ## PDB Nov 28, 2015 
     2307        # draw the model with the current dispersity 
     2308 
     2309        # Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
     2310        # By comenting it we save an extra Iq calculation 
     2311        # self._draw_model() 
     2312 
     2313        # Need to use FitInside again here to replace the next four lines. 
     2314        # Otherwised polydispersity off does not resize the scrollwindow. 
     2315        # PDB Nov 28, 2015 
    23122316        self.FitInside() 
    23132317#        self.sizer4_4.Layout() 
     
    23532357        self.weights = {} 
    23542358 
    2355         #from sas.models.dispersion_models import GaussianDispersion 
     2359        # from sas.models.dispersion_models import GaussianDispersion 
    23562360        from sasmodels.weights import GaussianDispersion 
    23572361        if len(self.disp_cb_dict) == 0: 
     
    23742378                    logging.error(traceback.format_exc()) 
    23752379 
    2376         ## save state into 
     2380        # save state into 
    23772381        self.save_current_state() 
    23782382        self.Layout() 
     
    23862390        self._set_sizer_dispersion() 
    23872391 
    2388         ## Redraw the model 
     2392        # Redraw the model 
    23892393        self._draw_model() 
    2390         #self._undo.Enable(True) 
     2394        # self._undo.Enable(True) 
    23912395        event = PageInfoEvent(page=self) 
    23922396        wx.PostEvent(self.parent, event) 
     
    24032407        """ 
    24042408        # get ready for new event 
    2405         if event != None: 
     2409        if event is not None: 
    24062410            event.Skip() 
    24072411        # Get event object 
     
    24162420            dispersity = disp_box.GetClientData(selection) 
    24172421 
    2418             #disp_model =  GaussianDispersion() 
     2422            # disp_model =  GaussianDispersion() 
    24192423            disp_model = dispersity() 
    24202424            # Get param names to reset the values of the param 
     
    24292433            else: 
    24302434                self._del_array_values(name1) 
    2431                 #self._reset_array_disp(param_name) 
     2435                # self._reset_array_disp(param_name) 
    24322436                self._disp_obj_dict[name1] = disp_model 
    24332437                self.model.set_dispersion(param_name, disp_model) 
     
    25132517        if path is None: 
    25142518            self.disp_cb_dict[name].SetValue(False) 
    2515             #self.noDisper_rbox.SetValue(True) 
     2519            # self.noDisper_rbox.SetValue(True) 
    25162520            return 
    25172521        self._default_save_location = os.path.dirname(path) 
    2518         if self._manager != None: 
     2522        if self._manager is not None: 
    25192523            self._manager.parent._default_save_location = \ 
    25202524                             self._default_save_location 
     
    25332537        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    25342538        self._set_array_disp_model(name=name, disp=disp, 
    2535                                     values=values, weights=weights) 
     2539                                   values=values, weights=weights) 
    25362540        return basename 
    25372541 
     
    25522556        # Store the object to make it persist outside the 
    25532557        # scope of this method 
    2554         #TODO: refactor model to clean this up? 
     2558        # TODO: refactor model to clean this up? 
    25552559        self.state.values = {} 
    25562560        self.state.weights = {} 
     
    25592563 
    25602564        # Set the new model as the dispersion object for the 
    2561         #selected parameter 
    2562         #self.model.set_dispersion(p, disp_model) 
     2565        # selected parameter 
     2566        # self.model.set_dispersion(p, disp_model) 
    25632567        # Store a reference to the weights in the model object 
    2564         #so that 
     2568        # so that 
    25652569        # it's not lost when we use the model within another thread. 
    25662570        self.state.model = self.model.clone() 
    25672571        self.model._persistency_dict[name.split('.')[0]] = \ 
    2568                                         [values, weights] 
     2572            [values, weights] 
    25692573        self.state.model._persistency_dict[name.split('.')[0]] = \ 
    2570                                         [values, weights] 
     2574            [values, weights] 
    25712575 
    25722576    def _del_array_values(self, name=None): 
     
    26062610            Layout after self._draw_model 
    26072611        """ 
    2608         if ON_MAC == True: 
     2612        if ON_MAC is True: 
    26092613            time.sleep(1) 
    26102614 
     
    26282632        """ 
    26292633        flag = True 
    2630         ##For 3 different cases: Data2D, Data1D, and theory 
    2631         if self.model == None: 
     2634        # For 3 different cases: Data2D, Data1D, and theory 
     2635        if self.model is None: 
    26322636            msg = "Please select a model first..." 
    26332637            wx.MessageBox(msg, 'Info') 
     
    26412645            self.qmin_x = data_min 
    26422646            self.qmax_x = math.sqrt(x * x + y * y) 
    2643             #self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2647            # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
    26442648            # check smearing 
    26452649            if not self.disable_smearer.GetValue(): 
    2646                 ## set smearing value whether or 
     2650                # set smearing value whether or 
    26472651                # not the data contain the smearing info 
    26482652                if self.pinhole_smearer.GetValue(): 
     
    26512655                    flag = True 
    26522656 
    2653         elif self.data == None: 
     2657        elif self.data is None: 
    26542658            self.qmin_x = _QMIN_DEFAULT 
    26552659            self.qmax_x = _QMAX_DEFAULT 
     
    26622666            # check smearing 
    26632667            if not self.disable_smearer.GetValue(): 
    2664                 ## set smearing value whether or 
     2668                # set smearing value whether or 
    26652669                # not the data contain the smearing info 
    26662670                if self.slit_smearer.GetValue(): 
     
    26732677            flag = False 
    26742678 
    2675         if flag == False: 
     2679        if flag is False: 
    26762680            msg = "Cannot Plot :Must enter a number!!!  " 
    26772681            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    26902694        self.state.qmax = self.qmax_x 
    26912695 
    2692         #reset the q range values 
     2696        # reset the q range values 
    26932697        self._reset_plotting_range(self.state) 
    26942698        self._draw_model() 
     
    27312735                logging.error(traceback.format_exc()) 
    27322736        # Make sure the resduals plot goes to the last 
    2733         if res_item != None: 
     2737        if res_item is not None: 
    27342738            graphs.append(res_item[0]) 
    27352739            canvases.append(res_item[1]) 
     
    27502754        the # to the browser. 
    27512755 
    2752         :param evt: on Help Button pressed event 
    2753         """ 
    2754  
    2755         if self.model != None: 
     2756        :param event: on Help Button pressed event 
     2757        """ 
     2758 
     2759        if self.model is not None: 
    27562760            name = self.formfactorbox.GetValue() 
    2757             _TreeLocation = 'user/models/'+ name.lower()+'.html' 
     2761            _TreeLocation = 'user/models/' + name.lower()+'.html' 
    27582762            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27592763                                              "", name + " Help") 
     
    27622766            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27632767                                              "", "General Model Help") 
    2764  
    27652768 
    27662769    def on_model_help_clicked(self, event): 
     
    27742777        give the message that none is available. 
    27752778 
    2776         :param evt: on Description Button pressed event 
    2777         """ 
    2778  
    2779         if self.model == None: 
     2779        :param event: on Description Button pressed event 
     2780        """ 
     2781 
     2782        if self.model is None: 
    27802783            name = 'index.html' 
    27812784        else: 
     
    27842787        msg = 'Model description:\n' 
    27852788        info = "Info" 
    2786         if self.model != None: 
    2787 #                frame.Destroy() 
     2789        if self.model is not None: 
     2790            # frame.Destroy() 
    27882791            if str(self.model.description).rstrip().lstrip() == '': 
    27892792                msg += "Sorry, no information is available for this model." 
     
    28542857            for key in self.model.magnetic_params: 
    28552858                if key.count('M0') > 0: 
    2856                     #reset mag value to zero fo safety 
     2859                    # reset mag value to zero fo safety 
    28572860                    self.model.setParam(key, 0.0) 
    28582861 
    28592862        self.Show(False) 
    28602863        self.set_model_param_sizer(self.model) 
    2861         #self._set_sizer_dispersion() 
     2864        # self._set_sizer_dispersion() 
    28622865        self.state.magnetic_on = self.magnetic_on 
    28632866        self.SetupScrolling() 
     
    28742877        running "file:///...." 
    28752878 
    2876         :param evt: Triggers on clicking ? in polydispersity box 
     2879        :param event: Triggers on clicking ? in polydispersity box 
    28772880        """ 
    28782881 
     
    29122915        content = 'sasview_parameter_values:' 
    29132916        # Do it if params exist 
    2914         if  self.parameters != []: 
     2917        if self.parameters: 
    29152918 
    29162919            # go through the parameters 
     
    29562959 
    29572960        # Do it if params exist 
    2958         if  self.parameters != []: 
     2961        if self.parameters: 
    29592962 
    29602963            for param in self.parameters: 
    2961                 content += param[1] #parameter name 
     2964                content += param[1]  # parameter name 
    29622965                content += tab 
    29632966                content += param[1] + "_err" 
     
    29662969            content += crlf 
    29672970 
    2968             #row of values and errors... 
     2971            # row of values and errors... 
    29692972            for param in self.parameters: 
    2970                 content += param[2].GetValue() #value 
     2973                content += param[2].GetValue()  # value 
    29712974                content += tab 
    2972                 content += param[4].GetValue() #error 
     2975                content += param[4].GetValue()  # error 
    29732976                content += tab 
    29742977 
     
    29762979        else: 
    29772980            return False 
    2978  
    29792981 
    29802982    def get_copy_latex(self): 
     
    29983000 
    29993001        # Do it if params exist 
    3000         if  self.parameters != []: 
     3002        if self.parameters: 
    30013003 
    30023004            content += '{|' 
     
    30073009 
    30083010            for index, param in enumerate(self.parameters): 
    3009                 content += param[1].replace('_', '\_') #parameter name 
     3011                content += param[1].replace('_', '\_')  # parameter name 
    30103012                content += ' & ' 
    30113013                content += param[1].replace('_', '\_') + "\_err" 
     
    30153017            content += crlf 
    30163018 
    3017             #row of values and errors... 
     3019            # row of values and errors... 
    30183020            for index, param in enumerate(self.parameters): 
    3019                 content += param[2].GetValue() #parameter value 
     3021                content += param[2].GetValue()  # parameter value 
    30203022                content += ' & ' 
    3021                 content += param[4].GetValue() #parameter error 
     3023                content += param[4].GetValue()  # parameter error 
    30223024                if index < len(self.parameters) - 1: 
    30233025                    content += ' & ' 
     
    30303032        else: 
    30313033            return False 
    3032  
    30333034 
    30343035    def set_clipboard(self, content=None): 
     
    30773078            # 1D 
    30783079            else: 
    3079                 ## for 1D all parameters except orientation 
     3080                # for 1D all parameters except orientation 
    30803081                if not item[1] in orient_param: 
    30813082                    try: 
     
    31093110            except Exception: 
    31103111                logging.error(traceback.format_exc()) 
    3111             content += name + ',' + str(check) + ',' +\ 
    3112                     value + disfunc + ',' + bound_lo + ',' +\ 
    3113                     bound_hi + ':' 
     3112            content += name + ',' + str(check) + ',' + value + disfunc + ',' + \ 
     3113                       bound_lo + ',' + bound_hi + ':' 
    31143114 
    31153115        return content 
     
    31893189 
    31903190        # Do it if params exist 
    3191         if  self.parameters != []: 
     3191        if self.parameters: 
    31923192            # go through the parameters 
    31933193            self._get_paste_helper(self.parameters, 
     
    32373237                                pd = int(pd) 
    32383238                        except Exception: 
    3239                             #continue 
     3239                            # continue 
    32403240                            if not pd and pd != '': 
    32413241                                continue 
     
    32653265                    else: 
    32663266                        is_true = None 
    3267                     if is_true != None: 
     3267                    if is_true is not None: 
    32683268                        item[0].SetValue(is_true) 
    32693269            # 1D 
    32703270            else: 
    3271                 ## for 1D all parameters except orientation 
     3271                # for 1D all parameters except orientation 
    32723272                if not item[1] in orient_param: 
    32733273                    name = item[1] 
     
    32783278                        pd = value[0] 
    32793279                        if name.count('.') > 0: 
    3280                             # If this is parameter.width, then pd may be a floating 
    3281                             # point value or it may be an array distribution. 
    3282                             # Nothing to do for parameter.npts or parameter.nsigmas. 
     3280                            # If this is parameter.width, then pd may be a 
     3281                            # floating point value or it may be an array 
     3282                            # distribution. Nothing to do for parameter.npts or 
     3283                            # parameter.nsigmas. 
    32833284                            try: 
    32843285                                pd = float(pd) 
     
    32863287                                    pd = int(pd) 
    32873288                            except: 
    3288                                 #continue 
     3289                                # continue 
    32893290                                if not pd and pd != '': 
    32903291                                    continue 
     
    33143315                        else: 
    33153316                            is_true = None 
    3316                         if is_true != None: 
     3317                        if is_true is not None: 
    33173318                            item[0].SetValue(is_true) 
    33183319 
     
    33813382            logging.error(traceback.format_exc()) 
    33823383            print "Error in BasePage._paste_poly_help: %s" % \ 
    3383                                     sys.exc_info()[1] 
     3384                  sys.exc_info()[1] 
    33843385 
    33853386    def _set_disp_cb(self, isarray, item): 
     
    34473448        self.categorybox.Clear() 
    34483449        cat_list = sorted(self.master_category_dict.keys()) 
    3449         if not uncat_str in cat_list: 
     3450        if uncat_str not in cat_list: 
    34503451            cat_list.append(uncat_str) 
    34513452 
     
    34573458            self.categorybox.SetSelection(0) 
    34583459        else: 
    3459             self.categorybox.SetSelection(\ 
     3460            self.categorybox.SetSelection( 
    34603461                self.categorybox.GetSelection()) 
    3461         #self._on_change_cat(None) 
     3462        # self._on_change_cat(None) 
    34623463 
    34633464    def _on_change_cat(self, event): 
     
    34673468        self.model_name = None 
    34683469        category = self.categorybox.GetStringSelection() 
    3469         if category == None: 
     3470        if category is None: 
    34703471            return 
    34713472        self.model_box.Clear() 
     
    34783479        else: 
    34793480            for (model, enabled) in sorted(self.master_category_dict[category], 
    3480                                       key=lambda name: name[0]): 
     3481                                           key=lambda name: name[0]): 
    34813482                if(enabled): 
    34823483                    self.model_box.Append(model) 
     
    34873488        """ 
    34883489        # This should only be called once per fit tab 
    3489         #print "==== Entering _fill_model_sizer" 
    3490         ##Add model function Details button in fitpanel. 
    3491         ##The following 3 lines are for Mac. Let JHC know before modifying... 
     3490        # print "==== Entering _fill_model_sizer" 
     3491        # Add model function Details button in fitpanel. 
     3492        # The following 3 lines are for Mac. Let JHC know before modifying... 
    34923493        title = "Model" 
    34933494        self.formfactorbox = None 
     
    35213522        self._populate_listbox() 
    35223523        wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 
    3523         #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
     3524        # self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
    35243525        #                                     style=wx.RB_GROUP) 
    3525         #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3526        # self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35263527        #                                          "Shape-Independent") 
    3527         #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3528        # self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35283529        #                                     "Structure Factor ") 
    3529         #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3530        # self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35303531        #                                     "Uncategorized") 
    35313532 
    3532         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3533        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35333534        #                   id=self.shape_rbutton.GetId()) 
    3534         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3535        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35353536        #                    id=self.shape_indep_rbutton.GetId()) 
    3536         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3537        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35373538        #                    id=self.struct_rbutton.GetId()) 
    3538         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3539        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35393540        #                    id=self.plugin_rbutton.GetId()) 
    3540         #MAC needs SetValue 
     3541        # MAC needs SetValue 
    35413542 
    35423543        show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 
    35433544        cat_tip = "Modify model categories \n" 
    35443545        cat_tip += "(also accessible from the menu bar)." 
    3545         show_cat_button.SetToolTip( wx.ToolTip(cat_tip) ) 
     3546        show_cat_button.SetToolTip(wx.ToolTip(cat_tip)) 
    35463547        show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat) 
    35473548        sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3) 
    3548         sizer_cat_box.Add((10,10)) 
     3549        sizer_cat_box.Add((10, 10)) 
    35493550        sizer_cat_box.Add(show_cat_button) 
    3550         #self.shape_rbutton.SetValue(True) 
     3551        # self.shape_rbutton.SetValue(True) 
    35513552 
    35523553        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    3553         #sizer_radiobutton.Add(self.shape_rbutton) 
    3554         #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3555         sizer_radiobutton.Add((5,5)) 
     3554        # sizer_radiobutton.Add(self.shape_rbutton) 
     3555        # sizer_radiobutton.Add(self.shape_indep_rbutton) 
     3556        sizer_radiobutton.Add((5, 5)) 
    35563557        sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 
    3557         #sizer_radiobutton.Add(self.plugin_rbutton) 
    3558         #sizer_radiobutton.Add(self.struct_rbutton) 
    3559 #        sizer_radiobutton.Add((5,5)) 
     3558        # sizer_radiobutton.Add(self.plugin_rbutton) 
     3559        # sizer_radiobutton.Add(self.struct_rbutton) 
     3560        # sizer_radiobutton.Add((5,5)) 
    35603561        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5) 
    3561 #        sizer_radiobutton.Add((5,5)) 
     3562        # sizer_radiobutton.Add((5,5)) 
    35623563        sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 
    35633564        sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 
     
    35753576        self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    35763577        self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 
    3577         if self.model != None: 
     3578        if self.model is not None: 
    35783579            self.formfactorbox.SetValue(self.model.name) 
    35793580        self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
     
    35843585        wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 
    35853586        wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 
    3586         ## check model type to show sizer 
    3587         if self.model != None: 
     3587        # check model type to show sizer 
     3588        if self.model is not None: 
    35883589            print "_set_model_sizer_selection: disabled." 
    3589             #self._set_model_sizer_selection(self.model) 
     3590            # self._set_model_sizer_selection(self.model) 
    35903591 
    35913592        sizer_selection.Add(self.text1) 
     
    36823683        """ 
    36833684 
     3685 
    36843686class ModelTextCtrl(wx.TextCtrl): 
    36853687    """ 
     
    36943696 
    36953697    """ 
    3696     ## Set to True when the mouse is clicked while whole string is selected 
     3698    # Set to True when the mouse is clicked while whole string is selected 
    36973699    full_selection = False 
    3698     ## Call back for EVT_SET_FOCUS events 
     3700    # Call back for EVT_SET_FOCUS events 
    36993701    _on_set_focus_callback = None 
    37003702 
     
    37183720            if set_focus_callback is None else set_focus_callback 
    37193721        self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 
    3720         self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \ 
    3721             if kill_focus_callback is None else kill_focus_callback) 
    3722         self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 
    3723             if text_enter_callback is None else text_enter_callback) 
     3722        self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus 
     3723        if kill_focus_callback is None else kill_focus_callback) 
     3724        self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter 
     3725        if text_enter_callback is None else text_enter_callback) 
    37243726        if not ON_MAC: 
    3725             self.Bind(wx.EVT_LEFT_UP, self._highlight_text \ 
    3726                 if mouse_up_callback is None else mouse_up_callback) 
     3727            self.Bind(wx.EVT_LEFT_UP, self._highlight_text 
     3728            if mouse_up_callback is None else mouse_up_callback) 
    37273729 
    37283730    def _on_set_focus(self, event): 
     
    37643766 
    37653767        event.Skip() 
    3766         #pass 
     3768        # pass 
Note: See TracChangeset for help on using the changeset viewer.