Ignore:
File:
1 edited

Legend:

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

    r55db501 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 
     
    142143        self.theory_qmin_x = None 
    143144        self.theory_qmax_x = None 
    144         self.cb1 = None 
    145145        self.btEditMask = None 
    146146        self.btFit = None 
     
    150150        self.disp_cb_dict = {} 
    151151 
    152         #self.state = PageState(parent=parent) 
    153         ## dictionary containing list of models 
     152        # self.state = PageState(parent=parent) 
     153        # dictionary containing list of models 
    154154        self.model_list_box = {} 
    155155 
    156         ## Data member to store the dispersion object created 
     156        # Data member to store the dispersion object created 
    157157        self._disp_obj_dict = {} 
    158         ## selected parameters to apply dispersion 
     158        # selected parameters to apply dispersion 
    159159        self.disp_cb_dict = {} 
    160         ## smearer object 
     160        # smearer object 
    161161        self.enable2D = False 
    162162        self._has_magnetic = False 
     
    166166        self.structurebox = None 
    167167        self.categorybox = None 
    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] 
     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] 
    171171        self.parameters = [] 
    172172        # non-fittable parameter whose value is astring 
    173173        self.str_parameters = [] 
    174         ## list of parameters to fit , must be like self.parameters 
     174        # list of parameters to fit , must be like self.parameters 
    175175        self.param_toFit = [] 
    176         ## list of looking like parameters but with non fittable parameters info 
     176        # list of looking like parameters but with non fittable parameters info 
    177177        self.fixed_param = [] 
    178         ## list of looking like parameters but with  fittable parameters info 
     178        # list of looking like parameters but with  fittable parameters info 
    179179        self.fittable_param = [] 
    180         ##list of dispersion parameters 
     180        # list of dispersion parameters 
    181181        self.disp_list = [] 
    182182        self.disp_name = "" 
    183183 
    184         ## list of orientation parameters 
     184        # list of orientation parameters 
    185185        self.orientation_params = [] 
    186186        self.orientation_params_disp = [] 
     
    189189#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
    190190#       it is pointless. 
    191 #        if self.model != None: 
     191#        if self.model is not None: 
    192192#            self.disp_list = self.model.getDispParamList() 
    193193        self.temp_multi_functional = False 
    194         ##enable model 2D draw 
     194        # enable model 2D draw 
    195195        self.enable2D = False 
    196         ## 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 
    197197        self.fitrange = True 
    198         ## Create memento to save the current state 
     198        # Create memento to save the current state 
    199199        self.state = PageState(parent=self.parent, 
    200200                               model=self.model, data=self.data) 
    201         ## flag to determine if state has change 
     201        # flag to determine if state has change 
    202202        self.state_change = False 
    203         ## save customized array 
     203        # save customized array 
    204204        self.values = {}   # type: Dict[str, List[float, ...]] 
    205205        self.weights = {}   # type: Dict[str, List[float, ...]] 
    206         ## retrieve saved state 
     206        # retrieve saved state 
    207207        self.number_saved_state = 0 
    208         ## dictionary of saved state 
     208        # dictionary of saved state 
    209209        self.saved_states = {} 
    210         ## Create context menu for page 
     210        # Create context menu for page 
    211211        self.popUpMenu = wx.Menu() 
    212212 
     
    221221        self.popUpMenu.AppendSeparator() 
    222222 
    223         ## Default locations 
     223        # Default locations 
    224224        self._default_save_location = os.getcwd() 
    225         ## save initial state on context menu 
    226         #self.onSave(event=None) 
     225        # save initial state on context menu 
     226        # self.onSave(event=None) 
    227227        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    228228 
     
    230230        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) 
    231231 
    232         ## create the basic structure of the panel with empty sizer 
     232        # create the basic structure of the panel with empty sizer 
    233233        self.define_page_structure() 
    234         ## drawing Initial dispersion parameters sizer 
     234        # drawing Initial dispersion parameters sizer 
    235235        self.set_dispers_sizer() 
    236236 
    237         ## layout 
     237        # layout 
    238238        self.set_layout() 
    239239 
     
    261261                    self._create_default_1d_data() 
    262262 
    263             if self.model != None: 
     263            if self.model is not None: 
    264264                if not self.data.is_data: 
    265                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    266                                                                 [self.data]) 
     265                    self._manager.page_finder[self.uid].set_fit_data( 
     266                        data=[self.data]) 
    267267            self.on_smear_helper(update=True) 
    268268            self.state.enable_smearer = self.enable_smearer.GetValue() 
     
    281281                           num=self.npts_x, endpoint=True) 
    282282        self.data = Data1D(x=x) 
    283         #self.data.xaxis('\\rm{Q}', "A^{-1}") 
    284         self.data.xaxis('\\rm{X}', "") 
    285         #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
    286         self.data.yaxis('\\rm{Y}', "") 
     283        self.data.xaxis('\\rm{Q}', "A^{-1}") 
     284        self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
    287285        self.data.is_data = False 
    288286        self.data.id = str(self.uid) + " data" 
     
    309307                           num=self.npts_x, endpoint=True, base=10.0) 
    310308        self.data = Data1D(x=x) 
    311         #self.data.xaxis('\\rm{Q}', "A^{-1}") 
    312         #self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
    313         self.data.xaxis('\\rm{X}', "") 
    314         self.data.yaxis('\\rm{Y}', "") 
     309        self.data.xaxis('\\rm{Q}', "A^{-1}") 
     310        self.data.yaxis('\\rm{Intensity}', "cm^{-1}") 
    315311        self.data.is_data = False 
    316312        self.data.id = str(self.uid) + " data" 
     
    330326        self.data.id = str(self.uid) + " data" 
    331327        self.data.group_id = str(self.uid) + " Model2D" 
    332         ## Default values 
     328        # Default values 
    333329        self.data.detector.append(Detector()) 
    334330        index = len(self.data.detector) - 1 
     
    347343        x = numpy.linspace(start=xmin, stop=xmax, num=qstep, endpoint=True) 
    348344        y = numpy.linspace(start=ymin, stop=ymax, num=qstep, endpoint=True) 
    349         ## use data info instead 
     345        # use data info instead 
    350346        new_x = numpy.tile(x, (len(y), 1)) 
    351347        new_y = numpy.tile(y, (len(x), 1)) 
     
    388384        Update menu1 on cliking the page tap 
    389385        """ 
    390         if self._manager.menu1 != None: 
    391             chain_menu = self._manager.menu1.FindItemById(\ 
     386        if self._manager.menu1 is not None: 
     387            chain_menu = self._manager.menu1.FindItemById( 
    392388                                                   self._manager.id_reset_flag) 
    393389            chain_menu.Enable(self.batch_on) 
    394390            sim_menu = self._manager.menu1.FindItemById(self._manager.id_simfit) 
    395391            flag = self.data.is_data\ 
    396                             and (self.model != None) 
     392                            and (self.model is not None) 
    397393            sim_menu.Enable(not self.batch_on and flag) 
    398394            batch_menu = \ 
     
    535531        fill sizer containing dispersity info 
    536532        """ 
    537         #print "==== entering set_dispers_sizer ===" 
     533        # print "==== entering set_dispers_sizer ===" 
    538534        self.sizer4.Clear(True) 
    539535        name = "Polydispersity and Orientational Distribution" 
     
    541537        box_description.SetForegroundColour(wx.BLUE) 
    542538        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    543         #---------------------------------------------------- 
     539        # ---------------------------------------------------- 
    544540        self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 
    545541                                           style=wx.RB_GROUP) 
     
    561557        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    562558                  id=self.enable_disp.GetId()) 
    563         #MAC needs SetValue 
     559        # MAC needs SetValue 
    564560        self.disable_disp.SetValue(True) 
    565561        sizer_dispersion = wx.BoxSizer(wx.HORIZONTAL) 
     
    573569        sizer_dispersion.Add(self.disp_help_bt) 
    574570 
    575         ## fill a sizer for dispersion 
     571        # fill a sizer for dispersion 
    576572        boxsizer1.Add(sizer_dispersion, 0, 
    577573                      wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 
     
    580576 
    581577        boxsizer1.Add(self.sizer4_4) 
    582         #----------------------------------------------------- 
     578        # ----------------------------------------------------- 
    583579        self.sizer4.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    584580        self.sizer4_4.Layout() 
     
    587583 
    588584        self.Refresh() 
    589         ## saving the state of enable dispersity button 
     585        # saving the state of enable dispersity button 
    590586        self.state.enable_disp = self.enable_disp.GetValue() 
    591587        self.state.disable_disp = self.disable_disp.GetValue() 
     
    597593        """ 
    598594        menu = event.GetEventObject() 
    599         ## post help message for the selected model 
     595        # post help message for the selected model 
    600596        msg = menu.GetHelpString(event.GetId()) 
    601597        msg += " reloaded" 
     
    604600        name = menu.GetLabel(event.GetId()) 
    605601        self._on_select_model_helper() 
    606         if self.model != None: 
     602        if self.model is not None: 
    607603            self.m_name = self.model.name 
    608604        if name in self.saved_states.keys(): 
    609605            previous_state = self.saved_states[name] 
    610             ## reset state of checkbox,textcrtl  and  regular parameters value 
     606            # reset state of checkbox,textcrtl  and  regular parameters value 
    611607 
    612608            self.reset_page(previous_state) 
     
    631627        # Ask the user the location of the file to write to. 
    632628        path = None 
    633         if self.parent != None: 
     629        if self.parent is not None: 
    634630            self._default_save_location = \ 
    635631                        self._manager.parent._default_save_location 
     
    641637            self._default_save_location = os.path.dirname(path) 
    642638            self._manager.parent._default_save_location = \ 
    643                                 self._default_save_location 
     639                self._default_save_location 
    644640        else: 
    645641            return None 
     
    648644        # Make sure the ext included in the file name 
    649645        fName = os.path.splitext(path)[0] + extens 
    650         #the manager write the state into file 
     646        # the manager write the state into file 
    651647        self._manager.save_fit_state(filepath=fName, fitstate=new_state) 
    652648        return new_state 
     
    656652        Copy Parameter values to the clipboad 
    657653        """ 
    658         if event != None: 
     654        if event is not None: 
    659655            event.Skip() 
    660656        # It seems MAC needs wxCallAfter 
     
    672668        Paste Parameter values to the panel if possible 
    673669        """ 
    674         #if event != None: 
     670        # if event is not None: 
    675671        #    event.Skip() 
    676672        # It seems MAC needs wxCallAfter for the setvalues 
     
    678674        wx.CallAfter(self.get_paste) 
    679675        # messages depending on the flag 
    680         #self._copy_info(True) 
     676        # self._copy_info(True) 
    681677 
    682678    def _copy_info(self, flag): 
     
    687683        """ 
    688684        # messages depending on the flag 
    689         if flag == None: 
     685        if flag is None: 
    690686            msg = " Parameter values are copied to the clipboard..." 
    691687            infor = 'warning' 
     
    715711        save history of the data and model 
    716712        """ 
    717         if self.model == None: 
     713        if self.model is None: 
    718714            msg = "Can not bookmark; Please select Data and Model first..." 
    719715            wx.MessageBox(msg, 'Info') 
     
    721717        self.save_current_state() 
    722718        new_state = self.state.clone() 
    723         ##Add model state on context menu 
     719        # Add model state on context menu 
    724720        self.number_saved_state += 1 
    725721        current_time, current_date = self._get_time_stamp() 
    726         #name= self.model.name+"[%g]"%self.number_saved_state 
     722        # name= self.model.name+"[%g]"%self.number_saved_state 
    727723        name = "Fitting: %g]" % self.number_saved_state 
    728724        name += self.model.__class__.__name__ 
     
    730726        self.saved_states[name] = new_state 
    731727 
    732         ## Add item in the context menu 
     728        # Add item in the context menu 
    733729        msg = "Model saved at %s on %s" % (current_time, current_date) 
    734         ## post help message for the selected model 
     730        # post help message for the selected model 
    735731        msg += " Saved! right click on this page to retrieve this model" 
    736732        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    766762        """ 
    767763        try: 
    768             if path == None: 
     764            if path is None: 
    769765                status = " Selected Distribution was not loaded: %s" % path 
    770766                wx.PostEvent(self._manager.parent, 
     
    801797        Store current state 
    802798        """ 
    803         ## save model option 
    804         if self.model != None: 
     799        # save model option 
     800        if self.model is not None: 
    805801            self.disp_list = self.model.getDispParamList() 
    806802            self.state.disp_list = copy.deepcopy(self.disp_list) 
    807803            self.state.model = self.model.clone() 
    808804 
    809             #model combobox: complex code because of mac's silent error 
    810             if self.structurebox != None: 
     805            # model combobox: complex code because of mac's silent error 
     806            if self.structurebox is not None: 
    811807                if self.structurebox.IsShown(): 
    812808                    self.state.structurecombobox = 'None' 
    813809                    s_select = self.structurebox.GetSelection() 
    814810                    if s_select > 0: 
    815                         self.state.structurecombobox = self.structurebox.\ 
    816                         GetString(s_select) 
    817             if self.formfactorbox != None: 
     811                        self.state.structurecombobox = \ 
     812                            self.structurebox.GetString(s_select) 
     813            if self.formfactorbox is not None: 
    818814                f_select = self.formfactorbox.GetSelection() 
    819815                if f_select > 0: 
    820                     self.state.formfactorcombobox = self.formfactorbox.\ 
    821                     GetString(f_select) 
    822         if self.categorybox != None: 
     816                    self.state.formfactorcombobox = \ 
     817                        self.formfactorbox.GetString(f_select) 
     818        if self.categorybox is not None: 
    823819            cb_select = self.categorybox.GetSelection() 
    824820            if cb_select > 0: 
    825                 self.state.categorycombobox = self.categorybox.\ 
    826                 GetString(cb_select) 
     821                self.state.categorycombobox = \ 
     822                    self.categorybox.GetString(cb_select) 
    827823 
    828824        self.state.enable2D = copy.deepcopy(self.enable2D) 
    829825        self.state.values = copy.deepcopy(self.values) 
    830826        self.state.weights = copy.deepcopy(self.weights) 
    831         ## save data 
     827        # save data 
    832828        self.state.data = copy.deepcopy(self.data) 
    833829        self.state.qmax_x = self.qmax_x 
     
    864860            self.state.values = copy.deepcopy(self.values) 
    865861            self.state.weights = copy.deepcopy(self.weights) 
    866         ## save plotting range 
     862        # save plotting range 
    867863        self._save_plotting_range() 
    868864 
     
    874870        self.state.str_parameters = [] 
    875871 
    876         ## save checkbutton state and txtcrtl values 
     872        # save checkbutton state and txtcrtl values 
    877873        self._copy_parameters_state(self.str_parameters, 
    878874                                    self.state.str_parameters) 
     
    886882                                    self.state.fittable_param) 
    887883        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    888         #save chisqr 
     884        # save chisqr 
    889885        self.state.tcChi = self.tcChi.GetValue() 
    890886 
     
    893889        Store current state for fit_page 
    894890        """ 
    895         ## save model option 
    896         if self.model != None: 
     891        # save model option 
     892        if self.model is not None: 
    897893            self.disp_list = self.model.getDispParamList() 
    898894            self.state.disp_list = copy.deepcopy(self.disp_list) 
     
    902898        self.state.values = copy.deepcopy(self.values) 
    903899        self.state.weights = copy.deepcopy(self.weights) 
    904         ## save data 
     900        # save data 
    905901        self.state.data = copy.deepcopy(self.data) 
    906902 
     
    923919        self.state.dI_sqrdata = copy.deepcopy(self.dI_sqrdata.GetValue()) 
    924920        self.state.dI_idata = copy.deepcopy(self.dI_idata.GetValue()) 
    925         if hasattr(self, "disp_box") and self.disp_box != None: 
     921        if hasattr(self, "disp_box") and self.disp_box is not None: 
    926922            self.state.disp_box = self.disp_box.GetCurrentSelection() 
    927923 
    928924            if len(self.disp_cb_dict) > 0: 
    929925                for k, v in self.disp_cb_dict.iteritems(): 
    930                     if v == None: 
     926                    if v is None: 
    931927                        self.state.disp_cb_dict[k] = v 
    932928                    else: 
     
    942938            self.state.weights = copy.deepcopy(self.weights) 
    943939 
    944         ## save plotting range 
     940        # save plotting range 
    945941        self._save_plotting_range() 
    946942 
    947         ## save checkbutton state and txtcrtl values 
     943        # save checkbutton state and txtcrtl values 
    948944        self._copy_parameters_state(self.orientation_params, 
    949945                                    self.state.orientation_params) 
     
    964960            msg = "Please load Data and select Model to start..." 
    965961            wx.MessageBox(msg, 'Info') 
    966             return  True 
     962            return True 
    967963 
    968964    def set_model_state(self, state): 
     
    973969        self.disp_list = state.disp_list 
    974970 
    975         ## fill model combobox 
     971        # fill model combobox 
    976972        self._show_combox_helper() 
    977         #select the current model 
     973        # select the current model 
    978974        try: 
    979975            # to support older version 
     
    10141010        self.structurebox.SetSelection(structfactor_pos) 
    10151011 
    1016         if state.multi_factor != None: 
     1012        if state.multi_factor is not None: 
    10171013            self.multifactorbox.SetSelection(state.multi_factor) 
    10181014 
    1019         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1015        # reset state of checkbox,textcrtl  and  regular parameters value 
    10201016        self._reset_parameters_state(self.orientation_params_disp, 
    10211017                                     state.orientation_params_disp) 
     
    10251021                                     state.str_parameters) 
    10261022        self._reset_parameters_state(self.parameters, state.parameters) 
    1027         ## display dispersion info layer 
     1023        # display dispersion info layer 
    10281024        self.enable_disp.SetValue(state.enable_disp) 
    10291025        self.disable_disp.SetValue(state.disable_disp) 
    10301026 
    1031         if hasattr(self, "disp_box") and self.disp_box != None: 
     1027        if hasattr(self, "disp_box") and self.disp_box is not None: 
    10321028            self.disp_box.SetSelection(state.disp_box) 
    10331029            n = self.disp_box.GetCurrentSelection() 
     
    10411037 
    10421038                    if hasattr(self.disp_cb_dict[item], "SetValue"): 
    1043                         self.disp_cb_dict[item].SetValue(\ 
     1039                        self.disp_cb_dict[item].SetValue( 
    10441040                                                    state.disp_cb_dict[item]) 
    10451041                        # Create the dispersion objects 
    10461042                        disp_model = POLYDISPERSITY_MODELS['array']() 
    10471043                        if hasattr(state, "values") and \ 
    1048                                  self.disp_cb_dict[item].GetValue() == True: 
     1044                                 self.disp_cb_dict[item].GetValue() is True: 
    10491045                            if len(state.values) > 0: 
    10501046                                self.values = state.values 
     
    10571053                        self._disp_obj_dict[item] = disp_model 
    10581054                        # Set the new model as the dispersion object 
    1059                         #for the selected parameter 
     1055                        # for the selected parameter 
    10601056                        self.model.set_dispersion(item, disp_model) 
    10611057 
     
    10671063                for item in keys: 
    10681064                    if item in self.disp_list and \ 
    1069                         not item in self.model.details: 
     1065                            item not in self.model.details: 
    10701066                        self.model.details[item] = ["", None, None] 
    10711067                self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    10721068                self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    1073         ## smearing info  restore 
     1069        # smearing info  restore 
    10741070        if hasattr(self, "enable_smearer"): 
    1075             ## set smearing value whether or not the data 
    1076             #contain the smearing info 
     1071            # set smearing value whether or not the data 
     1072            # contain the smearing info 
    10771073            self.enable_smearer.SetValue(state.enable_smearer) 
    10781074            self.disable_smearer.SetValue(state.disable_smearer) 
     
    10861082        self.dI_idata.SetValue(state.dI_idata) 
    10871083 
    1088         ## we have two more options for smearing 
     1084        # we have two more options for smearing 
    10891085        if self.pinhole_smearer.GetValue(): 
    10901086            self.onPinholeSmear(event=None) 
     
    10921088            self.onSlitSmear(event=None) 
    10931089 
    1094         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1090        # reset state of checkbox,textcrtl  and dispersity parameters value 
    10951091        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    10961092        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    10971093 
    1098         ## draw the model with previous parameters value 
     1094        # draw the model with previous parameters value 
    10991095        self._onparamEnter_helper() 
    11001096        self.select_param(event=None) 
    1101         #Save state_fit 
     1097        # Save state_fit 
    11021098        self.save_current_state_fit() 
    11031099        self._lay_out() 
     
    11131109                if state.formfactorcombobox in list_item: 
    11141110                    return self.categorybox.Items.index(key) 
     1111        return 0 
    11151112 
    11161113    def reset_page_helper(self, state): 
     
    11231120            state of the graphic interface 
    11241121        """ 
    1125         if state == None: 
     1122        if state is None: 
    11261123            return 
    11271124        # set data, etc. from the state 
    11281125        # reset page between theory and fitting from bookmarking 
    1129         #if state.data == None: 
    1130         #    data = None 
    1131         #else: 
    11321126        data = state.data 
    11331127 
    1134         if data == None: 
     1128        if data is None: 
    11351129            data_min = state.qmin 
    11361130            data_max = state.qmax 
     
    11561150        self.disp_list = state.disp_list 
    11571151 
    1158         ## set the state of the radio box 
    1159         #self.shape_rbutton.SetValue(state.shape_rbutton) 
    1160         #self.shape_indep_rbutton.SetValue(state.shape_indep_rbutton) 
    1161         #self.struct_rbutton.SetValue(state.struct_rbutton) 
    1162         #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1163  
    1164         ## fill model combobox 
     1152        # fill model combobox 
    11651153        self._show_combox_helper() 
    1166         #select the current model 
     1154        # select the current model 
    11671155        try: 
    11681156            # to support older version 
    11691157            category_pos = int(state.categorycombobox) 
    11701158        except: 
    1171             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) 
    11721163            state.categorycombobox = unicode(state.categorycombobox) 
    1173             category_pos = 0 
    11741164            if state.categorycombobox in self.categorybox.Items: 
    11751165                category_pos = self.categorybox.Items.index( 
     
    11941184        self.formfactorbox.Select(formfactor_pos) 
    11951185 
     1186        structfactor_pos = 0 
    11961187        try: 
    11971188            # to support older version 
     
    11991190        except: 
    12001191            if state.structurecombobox is not None: 
    1201                 structfactor_pos = 0 
    12021192                state.structurecombobox = unicode(state.structurecombobox) 
    12031193                for ind_struct in range(self.structurebox.GetCount()): 
    12041194                    if self.structurebox.GetString(ind_struct) == \ 
    1205                                                         (state.structurecombobox): 
     1195                                                    (state.structurecombobox): 
    12061196                        structfactor_pos = int(ind_struct) 
    12071197                        break 
     
    12091199        self.structurebox.SetSelection(structfactor_pos) 
    12101200 
    1211         if state.multi_factor != None: 
     1201        if state.multi_factor is not None: 
    12121202            self.multifactorbox.SetSelection(state.multi_factor) 
    12131203 
    1214         #draw the panel according to the new model parameter 
     1204        # draw the panel according to the new model parameter 
    12151205        self._on_select_model(event=None) 
    12161206 
    12171207        # take care of 2D button 
    1218         if data == None and self.model_view.IsEnabled(): 
     1208        if data is None and self.model_view.IsEnabled(): 
    12191209            if self.enable2D: 
    12201210                self.model_view.SetLabel("2D Mode") 
     
    12221212                self.model_view.SetLabel("1D Mode") 
    12231213 
    1224         ## set the select all check box to the a given state 
    1225         self.cb1.SetValue(state.cb1) 
    1226  
    1227         ## reset state of checkbox,textcrtl  and  regular parameters value 
     1214        # reset state of checkbox,textcrtl  and  regular parameters value 
    12281215        self._reset_parameters_state(self.orientation_params_disp, 
    12291216                                     state.orientation_params_disp) 
     
    12331220                                     state.str_parameters) 
    12341221        self._reset_parameters_state(self.parameters, state.parameters) 
    1235         ## display dispersion info layer 
     1222        # display dispersion info layer 
    12361223        self.enable_disp.SetValue(state.enable_disp) 
    12371224        self.disable_disp.SetValue(state.disable_disp) 
     
    12411228            self._set_dipers_Param(event=None) 
    12421229            self._reset_page_disp_helper(state) 
    1243         ##plotting range restore 
     1230        # plotting range restore 
    12441231        self._reset_plotting_range(state) 
    1245         ## smearing info  restore 
     1232        # smearing info  restore 
    12461233        if hasattr(self, "enable_smearer"): 
    1247             ## set smearing value whether or not the data 
    1248             #contain the smearing info 
     1234            # set smearing value whether or not the data 
     1235            # contain the smearing info 
    12491236            self.enable_smearer.SetValue(state.enable_smearer) 
    12501237            self.disable_smearer.SetValue(state.disable_smearer) 
     
    12641251            self.dI_idata.SetValue(False) 
    12651252 
    1266         ## we have two more options for smearing 
     1253        # we have two more options for smearing 
    12671254        if self.pinhole_smearer.GetValue(): 
    12681255            self.dx_min = state.dx_min 
    12691256            self.dx_max = state.dx_max 
    1270             if self.dx_min != None: 
     1257            if self.dx_min is not None: 
    12711258                self.smear_pinhole_min.SetValue(str(self.dx_min)) 
    1272             if self.dx_max != None: 
     1259            if self.dx_max is not None: 
    12731260                self.smear_pinhole_max.SetValue(str(self.dx_max)) 
    12741261            self.onPinholeSmear(event=None) 
     
    12761263            self.dxl = state.dxl 
    12771264            self.dxw = state.dxw 
    1278             if self.dxl != None: 
     1265            if self.dxl is not None: 
    12791266                self.smear_slit_height.SetValue(str(self.dxl)) 
    1280             if self.dxw != None: 
     1267            if self.dxw is not None: 
    12811268                self.smear_slit_width.SetValue(str(self.dxw)) 
    12821269            else: 
     
    12841271            self.onSlitSmear(event=None) 
    12851272 
    1286         ## reset state of checkbox,textcrtl  and dispersity parameters value 
     1273        # reset state of checkbox,textcrtl  and dispersity parameters value 
    12871274        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    12881275        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    12891276 
    1290         ## draw the model with previous parameters value 
     1277        # draw the model with previous parameters value 
    12911278        self._onparamEnter_helper() 
    1292         #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 
    12931280        self.tcChi.SetValue(str(self.state.tcChi)) 
    1294         ## reset context menu items 
     1281        # reset context menu items 
    12951282        self._reset_context_menu() 
    12961283 
    1297         ## 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 
    12981285        self.state = state.clone() 
    12991286        self.state.m_name = self.m_name 
     
    13061293        for item in keys: 
    13071294            if item in self.disp_list and \ 
    1308                 not item in self.model.details: 
     1295                            item not in self.model.details: 
    13091296                self.model.details[item] = ["", None, None] 
    1310         #for k,v in self.state.disp_cb_dict.iteritems(): 
     1297        # for k,v in self.state.disp_cb_dict.iteritems(): 
    13111298        self.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
    13121299        self.state.disp_cb_dict = copy.deepcopy(state.disp_cb_dict) 
     
    13151302 
    13161303        for key, disp_type in state._disp_obj_dict.iteritems(): 
    1317             #disp_model = disp 
     1304            # disp_model = disp 
    13181305            disp_model = POLYDISPERSITY_MODELS[disp_type]() 
    13191306            self._disp_obj_dict[key] = disp_model 
     
    13241311                self.model.set_dispersion(param_name, disp_model) 
    13251312                self.model._persistency_dict[key] = \ 
    1326                                  [state.values, state.weights] 
     1313                    [state.values, state.weights] 
    13271314            except Exception: 
    13281315                logging.error(traceback.format_exc()) 
    13291316            selection = self._find_polyfunc_selection(disp_model) 
    13301317            for list in self.fittable_param: 
    1331                 if list[1] == key and list[7] != None: 
     1318                if list[1] == key and list[7] is not None: 
    13321319                    list[7].SetSelection(selection) 
    13331320                    # For the array disp_model, set the values and weights 
     
    13541341                            logging.error(traceback.format_exc()) 
    13551342 
    1356         # Make sure the check box updated when all checked 
    1357         if self.cb1.GetValue(): 
    1358             self.select_all_param(None) 
    1359  
    13601343    def _selectDlg(self): 
    13611344        """ 
    13621345        open a dialog file to selected the customized dispersity 
    13631346        """ 
    1364         if self.parent != None: 
     1347        if self.parent is not None: 
    13651348            self._default_save_location = \ 
    13661349                        self._manager.parent.get_save_location() 
     
    13811364        for name, _ in self.state.saved_states.iteritems(): 
    13821365            self.number_saved_state += 1 
    1383             ## Add item in the context menu 
     1366            # Add item in the context menu 
    13841367            wx_id = ids.next() 
    13851368            msg = 'Save model and state %g' % self.number_saved_state 
     
    13981381        save radiobutton containing the type model that can be selected 
    13991382        """ 
    1400         #self.state.shape_rbutton = self.shape_rbutton.GetValue() 
    1401         #self.state.shape_indep_rbutton = self.shape_indep_rbutton.GetValue() 
    1402         #self.state.struct_rbutton = self.struct_rbutton.GetValue() 
    1403         #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() 
    14041387        self.state.structurecombobox = self.structurebox.GetLabel() 
    14051388        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    14061389        self.state.categorycombobox = self.categorybox.GetLabel() 
    14071390 
    1408         ## post state to fit panel 
     1391        # post state to fit panel 
    14091392        event = PageInfoEvent(page=self) 
    14101393        wx.PostEvent(self.parent, event) 
     
    14181401        self.state.npts = self.npts_x 
    14191402 
    1420     def _onparamEnter_helper(self,is_modified = False): 
     1403    def _onparamEnter_helper(self, is_modified=False): 
    14211404        """ 
    14221405        check if values entered by the user are changed and valid to replot 
     
    14241407        """ 
    14251408        # Flag to register when a parameter has changed. 
    1426         #is_modified = False 
     1409        # is_modified = False 
    14271410        self.fitrange = True 
    14281411        is_2Ddata = False 
    1429         #self._undo.Enable(True) 
     1412        # self._undo.Enable(True) 
    14301413        # check if 2d data 
    14311414        if self.data.__class__.__name__ == "Data2D": 
    14321415            is_2Ddata = True 
    1433         if self.model != None: 
    1434             #Either we get a is_modified = True passed in because 
    1435             #_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 
    14361419            # we need to check here ourselves. 
    14371420            if not is_modified: 
     
    14601443                self.fitrange = False 
    14611444 
    1462             if not self.data.is_data: 
    1463                 is_modified = True 
    1464  
    1465             ## if any value is modify draw model with new value 
     1445            # if any value is modify draw model with new value 
    14661446            if not self.fitrange: 
    1467                 #self.btFit.Disable() 
     1447                # self.btFit.Disable() 
    14681448                if is_2Ddata: 
    14691449                    self.btEditMask.Disable() 
     
    14781458                self._draw_model() 
    14791459                self.Refresh() 
     1460 
     1461        # logging.info("is_modified flag set to %g",is_modified) 
    14801462        return is_modified 
    14811463 
     
    14841466        make sure that update param values just before the fitting 
    14851467        """ 
    1486         #flag for qmin qmax check values 
     1468        # flag for qmin qmax check values 
    14871469        flag = True 
    14881470        self.fitrange = True 
    14891471        is_modified = False 
    14901472 
    1491         #wx.PostEvent(self._manager.parent, StatusEvent(status=" \ 
    1492         #updating ... ",type="update")) 
    1493  
    1494         ##So make sure that update param values on_Fit. 
    1495         #self._undo.Enable(True) 
    1496         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: 
    14971479            if self.Npts_total.GetValue() != self.Npts_fit.GetValue(): 
    14981480                if not self.data.is_data: 
    1499                     self._manager.page_finder[self.uid].set_fit_data(data=\ 
    1500                                                                 [self.data]) 
    1501             ##Check the values 
     1481                    self._manager.page_finder[self.uid].set_fit_data( 
     1482                        data=[self.data]) 
     1483            # Check the values 
    15021484            is_modified = (self._check_value_enter(self.fittable_param) 
    1503                             or self._check_value_enter(self.fixed_param) 
    1504                             or self._check_value_enter(self.parameters)) 
     1485                           or self._check_value_enter(self.fixed_param) 
     1486                           or self._check_value_enter(self.parameters)) 
    15051487 
    15061488            # If qmin and qmax have been modified, update qmin and qmax and 
     
    15431525                                              enable_smearer=enable_smearer, 
    15441526                                              draw=False) 
    1545                     if self.data != None: 
    1546                         index_data = ((self.qmin_x <= self.data.x) & \ 
     1527                    if self.data is not None: 
     1528                        index_data = ((self.qmin_x <= self.data.x) & 
    15471529                                      (self.data.x <= self.qmax_x)) 
    1548                         val = str(len(self.data.x[index_data == True])) 
     1530                        val = str(len(self.data.x[index_data is True])) 
    15491531                        self.Npts_fit.SetValue(val) 
    15501532                    else: 
     
    15661548            flag = False 
    15671549 
    1568         #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. 
    15691551        if not self.fitrange: 
    15701552            if self._is_2D(): 
    15711553                self.btEditMask.Disable() 
    15721554        else: 
    1573             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: 
    15741556                self.btEditMask.Enable(True) 
    15751557 
     
    15841566            logging.error(traceback.format_exc()) 
    15851567 
    1586         return flag,is_modified 
     1568        return flag, is_modified 
    15871569 
    15881570    def _reset_parameters_state(self, listtorestore, statelist): 
     
    15981580            item_page = listtorestore[j] 
    15991581            item_page_info = statelist[j] 
    1600             ##change the state of the check box for simple parameters 
    1601             if item_page[0] != None: 
     1582            # change the state of the check box for simple parameters 
     1583            if item_page[0] is not None: 
    16021584                item_page[0].SetValue(item_page_info[0]) 
    1603             if item_page[2] != None: 
     1585            if item_page[2] is not None: 
    16041586                item_page[2].SetValue(item_page_info[2]) 
    16051587                if item_page[2].__class__.__name__ == "ComboBox": 
     
    16071589                        fun_val = self.model.fun_list[item_page_info[2]] 
    16081590                        self.model.setParam(item_page_info[1], fun_val) 
    1609             if item_page[3] != None: 
    1610                 ## show or hide text +/- 
     1591            if item_page[3] is not None: 
     1592                # show or hide text +/- 
    16111593                if item_page_info[2]: 
    16121594                    item_page[3].Show(True) 
    16131595                else: 
    16141596                    item_page[3].Hide() 
    1615             if item_page[4] != None: 
    1616                 ## 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 
    16171599                if item_page_info[4][0]: 
    16181600                    item_page[4].Show(True) 
     
    16201602                else: 
    16211603                    item_page[3].Hide() 
    1622             if item_page[5] != None: 
    1623                 ## 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 
    16241606                item_page[5].Show(item_page_info[5][0]) 
    16251607                item_page[5].SetValue(item_page_info[5][1]) 
    16261608 
    1627             if item_page[6] != None: 
    1628                 ## 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 
    16291611                item_page[6].Show(item_page_info[6][0]) 
    16301612                item_page[6].SetValue(item_page_info[6][1]) 
     
    16421624            item_page = listtorestore[j] 
    16431625            item_page_info = statelist[j] 
    1644             ##change the state of the check box for simple parameters 
    1645  
    1646             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: 
    16471629                item_page[0].SetValue(format_number(item_page_info[0], True)) 
    16481630 
    1649             if item_page[2] != None: 
     1631            if item_page[2] is not None: 
    16501632                param_name = item_page_info[1] 
    16511633                value = item_page_info[2] 
     
    16701652 
    16711653            checkbox_state = None 
    1672             if item[0] != None: 
     1654            if item[0] is not None: 
    16731655                checkbox_state = item[0].GetValue() 
    16741656            parameter_name = item[1] 
    16751657            parameter_value = None 
    1676             if item[2] != None: 
     1658            if item[2] is not None: 
    16771659                parameter_value = item[2].GetValue() 
    16781660            static_text = None 
    1679             if item[3] != None: 
     1661            if item[3] is not None: 
    16801662                static_text = item[3].IsShown() 
    16811663            error_value = None 
    16821664            error_state = None 
    1683             if item[4] != None: 
     1665            if item[4] is not None: 
    16841666                error_value = item[4].GetValue() 
    16851667                error_state = item[4].IsShown() 
     
    16871669            min_value = None 
    16881670            min_state = None 
    1689             if item[5] != None: 
     1671            if item[5] is not None: 
    16901672                min_value = item[5].GetValue() 
    16911673                min_state = item[5].IsShown() 
     
    16931675            max_value = None 
    16941676            max_state = None 
    1695             if item[6] != None: 
     1677            if item[6] is not None: 
    16961678                max_value = item[6].GetValue() 
    16971679                max_state = item[6].IsShown() 
    16981680            unit = None 
    1699             if item[7] != None: 
     1681            if item[7] is not None: 
    17001682                unit = item[7].GetLabel() 
    17011683 
     
    17051687                              [max_state, max_value], unit]) 
    17061688 
    1707  
    17081689    def _draw_model(self, update_chisqr=True, source='model'): 
    17091690        """ 
     
    17241705        :param chisqr: update chisqr value [bool] 
    17251706        """ 
    1726         #if self.check_invalid_panel(): 
     1707        # if self.check_invalid_panel(): 
    17271708        #    return 
    1728         if self.model != None: 
     1709        if self.model is not None: 
    17291710            temp_smear = None 
    17301711            if hasattr(self, "enable_smearer"): 
     
    17381719            is_2d = self._is_2D() 
    17391720            self._manager.draw_model(self.model, 
    1740                                     data=self.data, 
    1741                                     smearer=temp_smear, 
    1742                                     qmin=float(self.qmin_x), 
    1743                                     qmax=float(self.qmax_x), 
    1744                                     page_id=self.uid, 
    1745                                     toggle_mode_on=toggle_mode_on, 
    1746                                     state=self.state, 
    1747                                     enable2D=is_2d, 
    1748                                     update_chisqr=update_chisqr, 
    1749                                     source='model', 
    1750                                     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) 
    17511732 
    17521733    def _on_show_sld(self, event=None): 
     
    17581739 
    17591740        from sas.sasgui.plottools import Data1D as pf_data1d 
    1760         #from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
     1741        # from sas.sasgui.perspectives.theory.profile_dialog import SLDPanel 
    17611742        from sas.sasgui.guiframe.local_perspectives.plotting.profile_dialog \ 
    1762         import SLDPanel 
     1743            import SLDPanel 
    17631744        sld_data = pf_data1d(x, y) 
    17641745        sld_data.name = 'SLD' 
     
    18131794        self.structurebox.Disable() 
    18141795        self.formfactorbox.Clear() 
    1815         if mod_cat == None: 
     1796        if mod_cat is None: 
    18161797            return 
    18171798        m_list = [] 
     
    18751856        """ 
    18761857        tcrtl = event.GetEventObject() 
    1877         #Clear msg if previously shown. 
     1858        # Clear msg if previously shown. 
    18781859        msg = "" 
    18791860        wx.PostEvent(self.parent, StatusEvent(status=msg)) 
     
    18941875                    tcrtl.SetBackgroundColour("pink") 
    18951876                    msg = "Model Error: wrong value entered: %s" % \ 
    1896                                     sys.exc_info()[1] 
     1877                          sys.exc_info()[1] 
    18971878                    wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    18981879                    return 
     
    19021883                wx.PostEvent(self.parent, StatusEvent(status=msg)) 
    19031884                return 
    1904             #Check if # of points for theory model are valid(>0). 
    1905             if self.npts != None: 
     1885            # Check if # of points for theory model are valid(>0). 
     1886            if self.npts is not None: 
    19061887                if check_float(self.npts): 
    19071888                    temp_npts = float(self.npts.GetValue()) 
     
    19191900        wx.PostEvent(self.parent, event) 
    19201901        self.state_change = False 
    1921         #Draw the model for a different range 
     1902        # Draw the model for a different range 
    19221903        if not self.data.is_data: 
    19231904            self.create_default_data() 
     
    19301911 
    19311912        tcrtl = event.GetEventObject() 
    1932         #Clear msg if previously shown. 
     1913        # Clear msg if previously shown. 
    19331914        msg = "" 
    19341915        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    19511932                    tcrtl.SetBackgroundColour("pink") 
    19521933                    msg = "Model Error: wrong value entered: %s" % \ 
    1953                                         sys.exc_info()[1] 
     1934                          sys.exc_info()[1] 
    19541935                    wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19551936                    return 
     
    19591940                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    19601941                return 
    1961             #Check if # of points for theory model are valid(>0). 
     1942            # Check if # of points for theory model are valid(>0). 
    19621943            if self.Npts_total.IsEditable(): 
    19631944                if check_float(self.Npts_total): 
     
    19771958        wx.PostEvent(self.parent, event) 
    19781959        self.state_change = False 
    1979         #Draw the model for a different range 
     1960        # Draw the model for a different range 
    19801961        self.create_default_data() 
    19811962        self._draw_model() 
     
    19851966        call back for model selection 
    19861967        """ 
    1987         ## reset dictionary containing reference to dispersion 
     1968        # reset dictionary containing reference to dispersion 
    19881969        self._disp_obj_dict = {} 
    19891970        self.disp_cb_dict = {} 
    19901971        self.temp_multi_functional = False 
    19911972        f_id = self.formfactorbox.GetCurrentSelection() 
    1992         #For MAC 
     1973        # For MAC 
    19931974        form_factor = None 
    19941975        if f_id >= 0: 
     
    19971978        if form_factor is None or \ 
    19981979            not hasattr(form_factor, 'is_form_factor') or \ 
    1999             not form_factor.is_form_factor: 
     1980                not form_factor.is_form_factor: 
    20001981            self.structurebox.Hide() 
    20011982            self.text2.Hide() 
     
    20091990            self.text2.Enable() 
    20101991 
    2011         if form_factor != None: 
     1992        if form_factor is not None: 
    20121993            # set multifactor for Mutifunctional models 
    20131994            if form_factor.is_multiplicity_model: 
     
    20171998                self._set_multfactor_combobox(multiplicity) 
    20181999                self._show_multfactor_combobox() 
    2019                 #ToDo: this info should be called directly from the model 
     2000                # ToDo: this info should be called directly from the model 
    20202001                text = form_factor.multiplicity_info[1]  # 'No. of Shells: ' 
    20212002 
     
    20262007 
    20272008                self.multi_factor = self.multifactorbox.GetClientData(m_id) 
    2028                 if self.multi_factor == None: 
     2009                if self.multi_factor is None: 
    20292010                    self.multi_factor = 0 
    20302011                self.multifactorbox.SetSelection(m_id) 
     
    20322013                text = '' 
    20332014                if form_factor.multiplicity_info[0] == \ 
    2034                                         len(form_factor.multiplicity_info[2]): 
     2015                        len(form_factor.multiplicity_info[2]): 
    20352016                    text = form_factor.multiplicity_info[2][self.multi_factor] 
    20362017                self.mutifactor_text1.SetLabel(text) 
     
    20532034        struct_factor = self.structurebox.GetClientData(s_id) 
    20542035 
    2055         if  struct_factor != None: 
    2056             from sas.sascalc.fit.MultiplicationModel import MultiplicationModel 
     2036        if struct_factor is not None: 
     2037            from sasmodels.sasview_model import MultiplicationModel 
    20572038            self.model = MultiplicationModel(form_factor(self.multi_factor), 
    20582039                                             struct_factor()) 
     
    20602041            if len(form_factor.non_fittable) > 0: 
    20612042                self.temp_multi_functional = True 
    2062         elif form_factor != None: 
     2043        elif form_factor is not None: 
    20632044            if self.multi_factor is not None: 
    20642045                self.model = form_factor(self.multi_factor) 
     
    20752056        else: 
    20762057            self._has_magnetic = False 
    2077         ## post state to fit panel 
     2058        # post state to fit panel 
    20782059        self.state.parameters = [] 
    20792060        self.state.model = self.model 
     
    20852066        self.Layout() 
    20862067 
    2087  
    20882068    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    20892069        """ 
     
    21052085            qmax = float(qmax_ctrl.GetValue()) 
    21062086            if qmin < qmax: 
    2107                 #Make sure to set both colours white. 
     2087                # Make sure to set both colours white. 
    21082088                qmin_ctrl.SetBackgroundColour(wx.WHITE) 
    21092089                qmin_ctrl.Refresh() 
     
    21252105        If valid, setvalues Npts_fit otherwise post msg. 
    21262106        """ 
    2127         #default flag 
     2107        # default flag 
    21282108        flag = True 
    21292109        # Theory 
    2130         if self.data == None and self.enable2D: 
     2110        if self.data is None and self.enable2D: 
    21312111            return flag 
    21322112        for data in self.data_list: 
     
    21342114            radius = numpy.sqrt(data.qx_data * data.qx_data + 
    21352115                                data.qy_data * data.qy_data) 
    2136             #get unmasked index 
     2116            # get unmasked index 
    21372117            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2138                             (radius <= float(self.qmax.GetValue())) 
     2118                         (radius <= float(self.qmax.GetValue())) 
    21392119            index_data = (index_data) & (data.mask) 
    21402120            index_data = (index_data) & (numpy.isfinite(data.data)) 
     
    21522132                flag = False 
    21532133            else: 
    2154                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2134                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21552135                self.fitrange = True 
    21562136 
     
    21622142        If valid, setvalues Npts_fit otherwise post msg. 
    21632143        """ 
    2164         #default flag 
     2144        # default flag 
    21652145        flag = True 
    21662146        # Theory 
    2167         if self.data == None: 
     2147        if self.data is None: 
    21682148            return flag 
    21692149        for data in self.data_list: 
    21702150            # q value from qx and qy 
    21712151            radius = data.x 
    2172             #get unmasked index 
     2152            # get unmasked index 
    21732153            index_data = (float(self.qmin.GetValue()) <= radius) & \ 
    2174                             (radius <= float(self.qmax.GetValue())) 
     2154                         (radius <= float(self.qmax.GetValue())) 
    21752155            index_data = (index_data) & (numpy.isfinite(data.y)) 
    21762156 
     
    21872167                flag = False 
    21882168            else: 
    2189                 self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
     2169                self.Npts_fit.SetValue(str(len(index_data[index_data is True]))) 
    21902170                self.fitrange = True 
    21912171 
     
    22072187        is_modified = False 
    22082188        for item in list: 
    2209             #skip angle parameters for 1D 
     2189            # skip angle parameters for 1D 
    22102190            if not self.enable2D and item in self.orientation_params: 
    22112191                continue 
     
    22522232                    max_ctrl.SetBackgroundColour("pink") 
    22532233                    max_ctrl.Refresh() 
    2254                     #msg = "Invalid fit range for %s: min must be smaller than max"%name 
    2255                     #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)) 
    22562238                    continue 
    22572239 
     
    22712253                    # The configuration has changed but it won't change the 
    22722254                    # computed curve so no need to set is_modified to True 
    2273                     #is_modified = True 
     2255                    # is_modified = True 
    22742256                    self.model.details[name][1:3] = low, high 
    22752257 
     
    22892271        Redraw the model with the default dispersity (Gaussian) 
    22902272        """ 
    2291         ## On selction if no model exists. 
    2292         if self.model == None: 
     2273        # On selction if no model exists. 
     2274        if self.model is None: 
    22932275            self.disable_disp.SetValue(True) 
    22942276            msg = "Please select a Model first..." 
     
    23002282        self._reset_dispersity() 
    23012283 
    2302         if self.model == None: 
     2284        if self.model is None: 
    23032285            self.model_disp.Hide() 
    23042286            self.sizer4_4.Clear(True) 
     
    23062288 
    23072289        if self.enable_disp.GetValue(): 
    2308             ## layout for model containing no dispersity parameters 
     2290            # layout for model containing no dispersity parameters 
    23092291 
    23102292            self.disp_list = self.model.getDispParamList() 
     
    23132295                self._layout_sizer_noDipers() 
    23142296            else: 
    2315                 ## set gaussian sizer 
     2297                # set gaussian sizer 
    23162298                self._on_select_Disp(event=None) 
    23172299        else: 
    23182300            self.sizer4_4.Clear(True) 
    23192301 
    2320         ## post state to fit panel 
     2302        # post state to fit panel 
    23212303        self.save_current_state() 
    2322         if event != None: 
     2304        if event is not None: 
    23232305            event = PageInfoEvent(page=self) 
    23242306            wx.PostEvent(self.parent, event) 
    2325         #draw the model with the current dispersity 
    2326  
    2327         #Wojtek P, Oct 8, 2016: Calling draw_model seems to be unessecary. 
    2328         #By comenting it we save an extra Iq calculation 
    2329         #self._draw_model() 
    2330  
    2331         ## Need to use FitInside again here to replace the next four lines. 
    2332         ## Otherwised polydispersity off does not resize the scrollwindow. 
    2333         ## 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 
    23342316        self.FitInside() 
    23352317#        self.sizer4_4.Layout() 
     
    23752357        self.weights = {} 
    23762358 
    2377         #from sas.models.dispersion_models import GaussianDispersion 
     2359        # from sas.models.dispersion_models import GaussianDispersion 
    23782360        from sasmodels.weights import GaussianDispersion 
    23792361        if len(self.disp_cb_dict) == 0: 
     
    23962378                    logging.error(traceback.format_exc()) 
    23972379 
    2398         ## save state into 
     2380        # save state into 
    23992381        self.save_current_state() 
    24002382        self.Layout() 
     
    24082390        self._set_sizer_dispersion() 
    24092391 
    2410         ## Redraw the model 
     2392        # Redraw the model 
    24112393        self._draw_model() 
    2412         #self._undo.Enable(True) 
     2394        # self._undo.Enable(True) 
    24132395        event = PageInfoEvent(page=self) 
    24142396        wx.PostEvent(self.parent, event) 
     
    24252407        """ 
    24262408        # get ready for new event 
    2427         if event != None: 
     2409        if event is not None: 
    24282410            event.Skip() 
    24292411        # Get event object 
     
    24382420            dispersity = disp_box.GetClientData(selection) 
    24392421 
    2440             #disp_model =  GaussianDispersion() 
     2422            # disp_model =  GaussianDispersion() 
    24412423            disp_model = dispersity() 
    24422424            # Get param names to reset the values of the param 
     
    24512433            else: 
    24522434                self._del_array_values(name1) 
    2453                 #self._reset_array_disp(param_name) 
     2435                # self._reset_array_disp(param_name) 
    24542436                self._disp_obj_dict[name1] = disp_model 
    24552437                self.model.set_dispersion(param_name, disp_model) 
     
    24992481                        item[2].Enable() 
    25002482 
    2501             # Make sure the check box updated when all checked 
    2502             if self.cb1.GetValue(): 
    2503                 #self.select_all_param(None) 
    2504                 self.get_all_checked_params() 
     2483            # Make sure the check box updated 
     2484            self.get_all_checked_params() 
    25052485 
    25062486            # update params 
     
    25372517        if path is None: 
    25382518            self.disp_cb_dict[name].SetValue(False) 
    2539             #self.noDisper_rbox.SetValue(True) 
     2519            # self.noDisper_rbox.SetValue(True) 
    25402520            return 
    25412521        self._default_save_location = os.path.dirname(path) 
    2542         if self._manager != None: 
     2522        if self._manager is not None: 
    25432523            self._manager.parent._default_save_location = \ 
    25442524                             self._default_save_location 
     
    25572537        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    25582538        self._set_array_disp_model(name=name, disp=disp, 
    2559                                     values=values, weights=weights) 
     2539                                   values=values, weights=weights) 
    25602540        return basename 
    25612541 
     
    25762556        # Store the object to make it persist outside the 
    25772557        # scope of this method 
    2578         #TODO: refactor model to clean this up? 
     2558        # TODO: refactor model to clean this up? 
    25792559        self.state.values = {} 
    25802560        self.state.weights = {} 
     
    25832563 
    25842564        # Set the new model as the dispersion object for the 
    2585         #selected parameter 
    2586         #self.model.set_dispersion(p, disp_model) 
     2565        # selected parameter 
     2566        # self.model.set_dispersion(p, disp_model) 
    25872567        # Store a reference to the weights in the model object 
    2588         #so that 
     2568        # so that 
    25892569        # it's not lost when we use the model within another thread. 
    25902570        self.state.model = self.model.clone() 
    25912571        self.model._persistency_dict[name.split('.')[0]] = \ 
    2592                                         [values, weights] 
     2572            [values, weights] 
    25932573        self.state.model._persistency_dict[name.split('.')[0]] = \ 
    2594                                         [values, weights] 
     2574            [values, weights] 
    25952575 
    25962576    def _del_array_values(self, name=None): 
     
    26302610            Layout after self._draw_model 
    26312611        """ 
    2632         if ON_MAC == True: 
     2612        if ON_MAC is True: 
    26332613            time.sleep(1) 
    26342614 
     
    26522632        """ 
    26532633        flag = True 
    2654         ##For 3 different cases: Data2D, Data1D, and theory 
    2655         if self.model == None: 
     2634        # For 3 different cases: Data2D, Data1D, and theory 
     2635        if self.model is None: 
    26562636            msg = "Please select a model first..." 
    26572637            wx.MessageBox(msg, 'Info') 
     
    26652645            self.qmin_x = data_min 
    26662646            self.qmax_x = math.sqrt(x * x + y * y) 
    2667             #self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
     2647            # self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
    26682648            # check smearing 
    26692649            if not self.disable_smearer.GetValue(): 
    2670                 ## set smearing value whether or 
     2650                # set smearing value whether or 
    26712651                # not the data contain the smearing info 
    26722652                if self.pinhole_smearer.GetValue(): 
     
    26752655                    flag = True 
    26762656 
    2677         elif self.data == None: 
     2657        elif self.data is None: 
    26782658            self.qmin_x = _QMIN_DEFAULT 
    26792659            self.qmax_x = _QMAX_DEFAULT 
     
    26862666            # check smearing 
    26872667            if not self.disable_smearer.GetValue(): 
    2688                 ## set smearing value whether or 
     2668                # set smearing value whether or 
    26892669                # not the data contain the smearing info 
    26902670                if self.slit_smearer.GetValue(): 
     
    26972677            flag = False 
    26982678 
    2699         if flag == False: 
     2679        if flag is False: 
    27002680            msg = "Cannot Plot :Must enter a number!!!  " 
    27012681            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
     
    27142694        self.state.qmax = self.qmax_x 
    27152695 
    2716         #reset the q range values 
     2696        # reset the q range values 
    27172697        self._reset_plotting_range(self.state) 
    27182698        self._draw_model() 
     
    27552735                logging.error(traceback.format_exc()) 
    27562736        # Make sure the resduals plot goes to the last 
    2757         if res_item != None: 
     2737        if res_item is not None: 
    27582738            graphs.append(res_item[0]) 
    27592739            canvases.append(res_item[1]) 
     
    27742754        the # to the browser. 
    27752755 
    2776         :param evt: on Help Button pressed event 
    2777         """ 
    2778  
    2779         if self.model != None: 
     2756        :param event: on Help Button pressed event 
     2757        """ 
     2758 
     2759        if self.model is not None: 
    27802760            name = self.formfactorbox.GetValue() 
    2781             _TreeLocation = 'user/models/'+ name.lower()+'.html' 
     2761            _TreeLocation = 'user/models/' + name.lower()+'.html' 
    27822762            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27832763                                              "", name + " Help") 
     
    27862766            _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    27872767                                              "", "General Model Help") 
    2788  
    27892768 
    27902769    def on_model_help_clicked(self, event): 
     
    27982777        give the message that none is available. 
    27992778 
    2800         :param evt: on Description Button pressed event 
    2801         """ 
    2802  
    2803         if self.model == None: 
     2779        :param event: on Description Button pressed event 
     2780        """ 
     2781 
     2782        if self.model is None: 
    28042783            name = 'index.html' 
    28052784        else: 
     
    28082787        msg = 'Model description:\n' 
    28092788        info = "Info" 
    2810         if self.model != None: 
    2811 #                frame.Destroy() 
     2789        if self.model is not None: 
     2790            # frame.Destroy() 
    28122791            if str(self.model.description).rstrip().lstrip() == '': 
    28132792                msg += "Sorry, no information is available for this model." 
     
    28782857            for key in self.model.magnetic_params: 
    28792858                if key.count('M0') > 0: 
    2880                     #reset mag value to zero fo safety 
     2859                    # reset mag value to zero fo safety 
    28812860                    self.model.setParam(key, 0.0) 
    28822861 
    28832862        self.Show(False) 
    28842863        self.set_model_param_sizer(self.model) 
    2885         #self._set_sizer_dispersion() 
     2864        # self._set_sizer_dispersion() 
    28862865        self.state.magnetic_on = self.magnetic_on 
    28872866        self.SetupScrolling() 
     
    28982877        running "file:///...." 
    28992878 
    2900         :param evt: Triggers on clicking ? in polydispersity box 
     2879        :param event: Triggers on clicking ? in polydispersity box 
    29012880        """ 
    29022881 
     
    29362915        content = 'sasview_parameter_values:' 
    29372916        # Do it if params exist 
    2938         if  self.parameters != []: 
     2917        if self.parameters: 
    29392918 
    29402919            # go through the parameters 
     
    29802959 
    29812960        # Do it if params exist 
    2982         if  self.parameters != []: 
     2961        if self.parameters: 
    29832962 
    29842963            for param in self.parameters: 
    2985                 content += param[1] #parameter name 
     2964                content += param[1]  # parameter name 
    29862965                content += tab 
    29872966                content += param[1] + "_err" 
     
    29902969            content += crlf 
    29912970 
    2992             #row of values and errors... 
     2971            # row of values and errors... 
    29932972            for param in self.parameters: 
    2994                 content += param[2].GetValue() #value 
     2973                content += param[2].GetValue()  # value 
    29952974                content += tab 
    2996                 content += param[4].GetValue() #error 
     2975                content += param[4].GetValue()  # error 
    29972976                content += tab 
    29982977 
     
    30002979        else: 
    30012980            return False 
    3002  
    30032981 
    30042982    def get_copy_latex(self): 
     
    30223000 
    30233001        # Do it if params exist 
    3024         if  self.parameters != []: 
     3002        if self.parameters: 
    30253003 
    30263004            content += '{|' 
     
    30313009 
    30323010            for index, param in enumerate(self.parameters): 
    3033                 content += param[1].replace('_', '\_') #parameter name 
     3011                content += param[1].replace('_', '\_')  # parameter name 
    30343012                content += ' & ' 
    30353013                content += param[1].replace('_', '\_') + "\_err" 
     
    30393017            content += crlf 
    30403018 
    3041             #row of values and errors... 
     3019            # row of values and errors... 
    30423020            for index, param in enumerate(self.parameters): 
    3043                 content += param[2].GetValue() #parameter value 
     3021                content += param[2].GetValue()  # parameter value 
    30443022                content += ' & ' 
    3045                 content += param[4].GetValue() #parameter error 
     3023                content += param[4].GetValue()  # parameter error 
    30463024                if index < len(self.parameters) - 1: 
    30473025                    content += ' & ' 
     
    30543032        else: 
    30553033            return False 
    3056  
    30573034 
    30583035    def set_clipboard(self, content=None): 
     
    31013078            # 1D 
    31023079            else: 
    3103                 ## for 1D all parameters except orientation 
     3080                # for 1D all parameters except orientation 
    31043081                if not item[1] in orient_param: 
    31053082                    try: 
     
    31333110            except Exception: 
    31343111                logging.error(traceback.format_exc()) 
    3135             content += name + ',' + str(check) + ',' +\ 
    3136                     value + disfunc + ',' + bound_lo + ',' +\ 
    3137                     bound_hi + ':' 
     3112            content += name + ',' + str(check) + ',' + value + disfunc + ',' + \ 
     3113                       bound_lo + ',' + bound_hi + ':' 
    31383114 
    31393115        return content 
     
    32133189 
    32143190        # Do it if params exist 
    3215         if  self.parameters != []: 
     3191        if self.parameters: 
    32163192            # go through the parameters 
    32173193            self._get_paste_helper(self.parameters, 
     
    32613237                                pd = int(pd) 
    32623238                        except Exception: 
    3263                             #continue 
     3239                            # continue 
    32643240                            if not pd and pd != '': 
    32653241                                continue 
     
    32893265                    else: 
    32903266                        is_true = None 
    3291                     if is_true != None: 
     3267                    if is_true is not None: 
    32923268                        item[0].SetValue(is_true) 
    32933269            # 1D 
    32943270            else: 
    3295                 ## for 1D all parameters except orientation 
     3271                # for 1D all parameters except orientation 
    32963272                if not item[1] in orient_param: 
    32973273                    name = item[1] 
     
    33023278                        pd = value[0] 
    33033279                        if name.count('.') > 0: 
    3304                             # If this is parameter.width, then pd may be a floating 
    3305                             # point value or it may be an array distribution. 
    3306                             # 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. 
    33073284                            try: 
    33083285                                pd = float(pd) 
     
    33103287                                    pd = int(pd) 
    33113288                            except: 
    3312                                 #continue 
     3289                                # continue 
    33133290                                if not pd and pd != '': 
    33143291                                    continue 
     
    33383315                        else: 
    33393316                            is_true = None 
    3340                         if is_true != None: 
     3317                        if is_true is not None: 
    33413318                            item[0].SetValue(is_true) 
     3319 
     3320        self.select_param(event=None) 
     3321        self.Refresh() 
    33423322 
    33433323    def _paste_poly_help(self, item, value): 
     
    34023382            logging.error(traceback.format_exc()) 
    34033383            print "Error in BasePage._paste_poly_help: %s" % \ 
    3404                                     sys.exc_info()[1] 
     3384                  sys.exc_info()[1] 
    34053385 
    34063386    def _set_disp_cb(self, isarray, item): 
     
    34683448        self.categorybox.Clear() 
    34693449        cat_list = sorted(self.master_category_dict.keys()) 
    3470         if not uncat_str in cat_list: 
     3450        if uncat_str not in cat_list: 
    34713451            cat_list.append(uncat_str) 
    34723452 
     
    34783458            self.categorybox.SetSelection(0) 
    34793459        else: 
    3480             self.categorybox.SetSelection(\ 
     3460            self.categorybox.SetSelection( 
    34813461                self.categorybox.GetSelection()) 
    3482         #self._on_change_cat(None) 
     3462        # self._on_change_cat(None) 
    34833463 
    34843464    def _on_change_cat(self, event): 
     
    34883468        self.model_name = None 
    34893469        category = self.categorybox.GetStringSelection() 
    3490         if category == None: 
     3470        if category is None: 
    34913471            return 
    34923472        self.model_box.Clear() 
     
    34993479        else: 
    35003480            for (model, enabled) in sorted(self.master_category_dict[category], 
    3501                                       key=lambda name: name[0]): 
     3481                                           key=lambda name: name[0]): 
    35023482                if(enabled): 
    35033483                    self.model_box.Append(model) 
     
    35083488        """ 
    35093489        # This should only be called once per fit tab 
    3510         #print "==== Entering _fill_model_sizer" 
    3511         ##Add model function Details button in fitpanel. 
    3512         ##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... 
    35133493        title = "Model" 
    35143494        self.formfactorbox = None 
     
    35423522        self._populate_listbox() 
    35433523        wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 
    3544         #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
     3524        # self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
    35453525        #                                     style=wx.RB_GROUP) 
    3546         #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3526        # self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35473527        #                                          "Shape-Independent") 
    3548         #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3528        # self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35493529        #                                     "Structure Factor ") 
    3550         #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3530        # self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    35513531        #                                     "Uncategorized") 
    35523532 
    3553         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3533        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35543534        #                   id=self.shape_rbutton.GetId()) 
    3555         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3535        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35563536        #                    id=self.shape_indep_rbutton.GetId()) 
    3557         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3537        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35583538        #                    id=self.struct_rbutton.GetId()) 
    3559         #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
     3539        # self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35603540        #                    id=self.plugin_rbutton.GetId()) 
    3561         #MAC needs SetValue 
     3541        # MAC needs SetValue 
    35623542 
    35633543        show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 
    35643544        cat_tip = "Modify model categories \n" 
    35653545        cat_tip += "(also accessible from the menu bar)." 
    3566         show_cat_button.SetToolTip( wx.ToolTip(cat_tip) ) 
     3546        show_cat_button.SetToolTip(wx.ToolTip(cat_tip)) 
    35673547        show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat) 
    35683548        sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3) 
    3569         sizer_cat_box.Add((10,10)) 
     3549        sizer_cat_box.Add((10, 10)) 
    35703550        sizer_cat_box.Add(show_cat_button) 
    3571         #self.shape_rbutton.SetValue(True) 
     3551        # self.shape_rbutton.SetValue(True) 
    35723552 
    35733553        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    3574         #sizer_radiobutton.Add(self.shape_rbutton) 
    3575         #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3576         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)) 
    35773557        sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 
    3578         #sizer_radiobutton.Add(self.plugin_rbutton) 
    3579         #sizer_radiobutton.Add(self.struct_rbutton) 
    3580 #        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)) 
    35813561        sizer_radiobutton.Add(self.model_help, 1, wx.RIGHT | wx.LEFT, 5) 
    3582 #        sizer_radiobutton.Add((5,5)) 
     3562        # sizer_radiobutton.Add((5,5)) 
    35833563        sizer_radiobutton.Add(self.model_func, 1, wx.RIGHT, 5) 
    35843564        sizer_cat.Add(sizer_cat_box, 1, wx.LEFT, 2.5) 
     
    35963576        self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    35973577        self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 
    3598         if self.model != None: 
     3578        if self.model is not None: 
    35993579            self.formfactorbox.SetValue(self.model.name) 
    36003580        self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
     
    36053585        wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 
    36063586        wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 
    3607         ## check model type to show sizer 
    3608         if self.model != None: 
     3587        # check model type to show sizer 
     3588        if self.model is not None: 
    36093589            print "_set_model_sizer_selection: disabled." 
    3610             #self._set_model_sizer_selection(self.model) 
     3590            # self._set_model_sizer_selection(self.model) 
    36113591 
    36123592        sizer_selection.Add(self.text1) 
     
    36813661        call back for model selection if implemented 
    36823662        """ 
    3683     def select_all_param(self, event): 
    3684         """ 
    3685         set to true or false all checkBox if implemented 
    3686         """ 
    36873663    def get_weight_flag(self): 
    36883664        """ 
     
    37063682        toggle view of model from 1D to 2D  or 2D from 1D if implemented 
    37073683        """ 
     3684 
    37083685 
    37093686class ModelTextCtrl(wx.TextCtrl): 
     
    37193696 
    37203697    """ 
    3721     ## 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 
    37223699    full_selection = False 
    3723     ## Call back for EVT_SET_FOCUS events 
     3700    # Call back for EVT_SET_FOCUS events 
    37243701    _on_set_focus_callback = None 
    37253702 
     
    37433720            if set_focus_callback is None else set_focus_callback 
    37443721        self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 
    3745         self.Bind(wx.EVT_KILL_FOCUS, self._silent_kill_focus \ 
    3746             if kill_focus_callback is None else kill_focus_callback) 
    3747         self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 
    3748             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) 
    37493726        if not ON_MAC: 
    3750             self.Bind(wx.EVT_LEFT_UP, self._highlight_text \ 
    3751                 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) 
    37523729 
    37533730    def _on_set_focus(self, event): 
     
    37893766 
    37903767        event.Skip() 
    3791         #pass 
     3768        # pass 
Note: See TracChangeset for help on using the changeset viewer.