Ignore:
File:
1 edited

Legend:

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

    r1c2bf90 rf0d720b  
    1515from wx.lib.scrolledpanel import ScrolledPanel 
    1616from sas.guiframe.panel_base import PanelBase 
    17 from sas.guiframe.utils import format_number, check_float, IdList 
     17from sas.guiframe.utils import format_number, check_float 
    1818from sas.guiframe.events import PanelOnFocusEvent 
    1919from sas.guiframe.events import StatusEvent 
     
    5757    ## Title to appear on top of the window 
    5858    window_caption = "Fit Page " 
    59     # These two buttons have specific IDs since they seem to be created more 
    60     # frequently than they need to.  In particular, set_dispers_sizer() is 
    61     # called by _on_select_model 
    62     ID_BOOKMARK = wx.NewId() 
    63     ID_DISPERSER_HELP = wx.NewId() 
    64     _id_pool = IdList() 
    65  
     59     
    6660    def __init__(self, parent, color='blue', **kwargs): 
    6761        """ 
     
    7266        #Set window's font size 
    7367        self.SetWindowVariant(variant=FONT_VARIANT) 
     68       
    7469        self.SetBackgroundColour(color) 
    75  
    76         self._ids = iter(self._id_pool) 
    7770        ## parent of the page 
    7871        self.parent = parent 
     
    133126        self.Npts_fit = None 
    134127        self.Npts_total = None 
    135         self.theory_qmin = None 
     128        self.theory_qmin = None  
    136129        self.theory_qmax = None 
    137130        self.theory_qmin_x = None 
     
    142135        self.sld_axes = None 
    143136        self.multi_factor = None 
    144  
     137        
    145138        self.disp_cb_dict = {} 
    146  
     139    
    147140        #self.state = PageState(parent=parent) 
    148141        ## dictionary containing list of models 
    149142        self.model_list_box = {} 
    150  
     143        
    151144        ## Data member to store the dispersion object created 
    152145        self._disp_obj_dict = {} 
     
    176169        self.disp_list = [] 
    177170        self.disp_name = "" 
    178  
     171         
    179172        ## list of orientation parameters 
    180173        self.orientation_params = [] 
    181174        self.orientation_params_disp = [] 
    182 #       Self.model should ALWAYS be None here.  It was set to none above in 
     175#       Self.model should ALWAYS be None here.  It was set to none above in  
    183176#       this long init setting.  no obvious function call in between setting 
    184 #       and this - commenting out on 4/8/2014 by PDB.  Remove once clear 
     177#       and this - commenting out on 4/8/2014 by PDB.  Remove once clear  
    185178#       it is pointless. 
    186179#        if self.model != None: 
     
    205198        ## Create context menu for page 
    206199        self.popUpMenu = wx.Menu() 
    207  
    208         wx_id = self._ids.next() 
    209         self._keep = wx.MenuItem(self.popUpMenu, wx_id, "Add bookmark", 
     200     
     201        id = wx.NewId() 
     202        self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark", 
    210203                                 " Keep the panel status to recall it later") 
    211204        self.popUpMenu.AppendItem(self._keep) 
     
    213206        self._set_bookmark_flag(False) 
    214207        self._set_save_flag(False) 
    215         wx.EVT_MENU(self, wx_id, self.on_bookmark) 
     208        wx.EVT_MENU(self, id, self.on_bookmark) 
    216209        self.popUpMenu.AppendSeparator() 
    217  
     210     
    218211        ## Default locations 
    219212        self._default_save_location = os.getcwd() 
     
    221214        #self.onSave(event=None) 
    222215        self.Bind(wx.EVT_CONTEXT_MENU, self.onContextMenu) 
    223  
     216         
    224217        # bind key event 
    225218        self.Bind(wx.EVT_LEFT_DOWN, self.on_left_down) 
    226  
     219         
    227220        ## create the basic structure of the panel with empty sizer 
    228221        self.define_page_structure() 
    229222        ## drawing Initial dispersion parameters sizer 
    230223        self.set_dispers_sizer() 
    231  
     224         
    232225        ## layout 
    233226        self.set_layout() 
    234  
     227     
    235228    def set_index_model(self, index): 
    236229        """ 
     
    238231        """ 
    239232        self.index_model = index 
    240  
     233         
    241234    def create_default_data(self): 
    242235        """ 
     
    255248                else: 
    256249                    self._create_default_1d_data() 
    257  
     250                         
    258251            if self.model != None: 
    259252                if not self.data.is_data: 
     
    265258            self.state.pinhole_smearer = self.pinhole_smearer.GetValue() 
    266259            self.state.slit_smearer = self.slit_smearer.GetValue() 
    267  
     260         
    268261    def _create_default_1d_data(self): 
    269262        """ 
     
    271264        Only when the page is on theory mode. 
    272265        :warning: This data is never plotted. 
    273  
     266         
    274267        """ 
    275268        x = numpy.linspace(start=self.qmin_x, stop=self.qmax_x, 
     
    281274        self.data.id = str(self.uid) + " data" 
    282275        self.data.group_id = str(self.uid) + " Model1D" 
    283  
     276          
    284277    def _create_log_1d_data(self): 
    285278        """ 
     
    287280        Only when the page is on theory mode. 
    288281        :warning: This data is never plotted. 
    289  
     282         
    290283        """ 
    291284        if self.qmin_x >= 1.e-10: 
    292285            qmin = numpy.log10(self.qmin_x) 
    293286        else: 
    294             qmin = -10. 
    295  
     287            qmin = -10.     
     288             
    296289        if self.qmax_x <= 1.e10: 
    297290            qmax = numpy.log10(self.qmax_x) 
    298291        else: 
    299             qmax = 10. 
    300  
     292            qmax = 10.  
     293                
    301294        x = numpy.logspace(start=qmin, stop=qmax, 
    302295                           num=self.npts_x, endpoint=True, base=10.0) 
     
    307300        self.data.id = str(self.uid) + " data" 
    308301        self.data.group_id = str(self.uid) + " Model1D" 
    309  
     302       
    310303    def _create_default_2d_data(self): 
    311304        """ 
     
    365358        #xstep = x_size / len(x_bins - 1) 
    366359        #ystep = y_size / len(y_bins - 1) 
    367  
     360   
    368361        self.data.source = Source() 
    369362        self.data.data = numpy.ones(len(mask)) 
     
    388381            wx.PostEvent(self._manager.parent, PanelOnFocusEvent(panel=self)) 
    389382            self.on_tap_focus() 
    390  
     383                
    391384    def on_tap_focus(self): 
    392385        """ 
     
    404397                    self._manager.menu1.FindItemById(self._manager.id_batchfit) 
    405398            batch_menu.Enable(self.batch_on and flag) 
    406  
     399     
    407400    def set_page_info(self, page_info): 
    408401        """ 
    409402        set some page important information at once 
    410403        """ 
    411 #       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program 
     404#       THIS METHOD/FUNCTION NO LONGE APPEARS TO BE CALLED.  Started up program  
    412405#       and started new fit window and PR and Invariant and a fit in fitting 
    413406#       but never entered this routine which should be an initialization 
    414 #       routine.  Leave for a while but probably something to clean up at 
     407#       routine.  Leave for a while but probably something to clean up at  
    415408#       some point? 
    416409# 
     
    433426        ## Data member to store the dispersion object created 
    434427        self.populate_box(model_dict=self.model_list_box) 
    435  
     428         
    436429    def onContextMenu(self, event): 
    437430        """ 
     
    440433        # Skipping the save state functionality for release 0.9.0 
    441434        #return 
    442  
     435     
    443436        pos = event.GetPosition() 
    444437        pos = self.ScreenToClient(pos) 
    445  
     438        
    446439        self.PopupMenu(self.popUpMenu, pos) 
    447  
     440       
    448441    def onUndo(self, event): 
    449442        """ 
     
    452445        event = PreviousStateEvent(page=self) 
    453446        wx.PostEvent(self.parent, event) 
    454  
     447         
    455448    def onRedo(self, event): 
    456449        """ 
     
    459452        event = NextStateEvent(page=self) 
    460453        wx.PostEvent(self.parent, event) 
    461  
     454     
    462455    def define_page_structure(self): 
    463456        """ 
     
    472465        self.sizer5 = wx.BoxSizer(wx.VERTICAL) 
    473466        self.sizer6 = wx.BoxSizer(wx.VERTICAL) 
    474  
     467         
    475468        self.sizer0.SetMinSize((PANEL_WIDTH, -1)) 
    476469        self.sizer1.SetMinSize((PANEL_WIDTH, -1)) 
     
    480473        self.sizer5.SetMinSize((PANEL_WIDTH, -1)) 
    481474        self.sizer6.SetMinSize((PANEL_WIDTH, -1)) 
    482  
     475         
    483476        self.vbox.Add(self.sizer0) 
    484477        self.vbox.Add(self.sizer1) 
     
    488481        self.vbox.Add(self.sizer5) 
    489482        self.vbox.Add(self.sizer6) 
    490  
     483         
    491484    def set_layout(self): 
    492485        """ 
     
    497490        self.SetSizer(self.vbox) 
    498491        self.Centre() 
    499  
     492  
    500493    def set_owner(self, owner): 
    501494        """ 
    502495        set owner of fitpage 
    503  
     496         
    504497        :param owner: the class responsible of plotting 
    505  
     498         
    506499        """ 
    507500        self.event_owner = owner 
    508501        self.state.event_owner = owner 
    509  
     502         
    510503    def get_state(self): 
    511504        """ 
     
    513506        """ 
    514507        return self.state 
    515  
     508     
    516509    def get_data(self): 
    517510        """ 
     
    519512        """ 
    520513        return self.data 
    521  
     514     
    522515    def get_data_list(self): 
    523516        """ 
     
    525518        """ 
    526519        return self.data_list 
    527  
     520     
    528521    def set_manager(self, manager): 
    529522        """ 
    530523        set panel manager 
    531  
     524         
    532525        :param manager: instance of plugin fitting 
    533  
     526         
    534527        """ 
    535528        self._manager = manager 
    536529        self.state.manager = manager 
    537  
     530         
    538531    def populate_box(self, model_dict): 
    539532        """ 
    540533        Store list of model 
    541  
     534         
    542535        :param model_dict: dictionary containing list of models 
    543  
     536         
    544537        """ 
    545538        self.model_list_box = model_dict 
    546539        self.state.model_list_box = self.model_list_box 
    547540        self.initialize_combox() 
    548  
     541         
    549542    def set_model_dictionary(self, model_dict): 
    550543        """ 
     
    558551        """ 
    559552        put default value in the combobox 
    560         """ 
     553        """   
    561554        ## fill combox box 
    562555        if self.model_list_box is None: 
     
    567560        ## These are called for first time by formfactor_combo_init 
    568561        ## itself called from fitpanel only.  If we find that I'm wrong and 
    569         ## we DO need to initialize somehow here - do it by a call to 
    570         ## formfactor_combo_init 
     562        ## we DO need to initialize somehow here - do it by a call to  
     563        ## formfactor_combo_init  
    571564        ## self.formfator_combo_init() 
    572         ## BUT NOT HERE -- make it last line of this 
     565        ## BUT NOT HERE -- make it last line of this  
    573566        ## method so that structure box is populated before _show_comboox_helper 
    574567        ## is called.  Otherwise wx will complain mightily:-) 
     
    582575#                               self.model_list_box["Shapes"]) 
    583576            self._populate_box(self.structurebox, 
    584                                self.model_list_box["Structure Factors"]) 
     577                                self.model_list_box["Structure Factors"]) 
    585578            self.structurebox.Insert("None", 0, None) 
    586579            self.structurebox.SetSelection(0) 
     
    589582            self.structurebox.Disable() 
    590583            self.text2.Disable() 
    591  
     584              
    592585            if self.model.__class__ in self.model_list_box["P(Q)*S(Q)"]: 
    593586                self.structurebox.Show() 
     
    596589                self.text2.Enable() 
    597590 
    598  
     591                 
    599592    def set_dispers_sizer(self): 
    600593        """ 
    601594        fill sizer containing dispersity info 
    602595        """ 
    603         #print "==== entering set_dispers_sizer ===" 
    604596        self.sizer4.Clear(True) 
    605597        name = "Polydispersity and Orientational Distribution" 
    606         box_description = wx.StaticBox(self, wx.ID_ANY, name) 
     598        box_description = wx.StaticBox(self, -1, name) 
    607599        box_description.SetForegroundColour(wx.BLUE) 
    608600        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    609601        #---------------------------------------------------- 
    610         self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 
    611                                            style=wx.RB_GROUP) 
    612         self.enable_disp = wx.RadioButton(self, wx.ID_ANY, 'On', (10, 30)) 
     602        self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10), 
     603                                            style=wx.RB_GROUP) 
     604        self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30)) 
    613605        # best size for MAC and PC 
    614606        if ON_MAC: 
     
    616608        else: 
    617609            size_q = (20, 15) 
    618         self.disp_help_bt = wx.Button(self, self.ID_DISPERSER_HELP, '?', 
     610        self.disp_help_bt = wx.Button(self, wx.NewId(), '?', 
    619611                                      style=wx.BU_EXACTFIT, 
    620612                                      size=size_q) 
     
    622614                               id=self.disp_help_bt.GetId()) 
    623615        self.disp_help_bt.SetToolTipString("Helps for Polydispersion.") 
    624  
     616         
    625617        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    626                   id=self.disable_disp.GetId()) 
     618                     id=self.disable_disp.GetId()) 
    627619        self.Bind(wx.EVT_RADIOBUTTON, self._set_dipers_Param, 
    628                   id=self.enable_disp.GetId()) 
     620                   id=self.enable_disp.GetId()) 
    629621        #MAC needs SetValue 
    630622        self.disable_disp.SetValue(True) 
     
    632624        sizer_dispersion.Add((20, 20)) 
    633625        name = ""  # Polydispersity and \nOrientational Distribution " 
    634         sizer_dispersion.Add(wx.StaticText(self, wx.ID_ANY, name)) 
     626        sizer_dispersion.Add(wx.StaticText(self, -1, name)) 
    635627        sizer_dispersion.Add(self.enable_disp) 
    636628        sizer_dispersion.Add((20, 20)) 
     
    638630        sizer_dispersion.Add((25, 20)) 
    639631        sizer_dispersion.Add(self.disp_help_bt) 
    640  
     632         
    641633        ## fill a sizer for dispersion 
    642634        boxsizer1.Add(sizer_dispersion, 0, 
    643                       wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 
    644                       border=5) 
     635                wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 
     636                border=5) 
    645637        self.sizer4_4 = wx.GridBagSizer(6, 5) 
    646638 
     
    651643        self.sizer4.Layout() 
    652644        self.Layout() 
    653  
     645      
    654646        self.Refresh() 
    655647        ## saving the state of enable dispersity button 
     
    657649        self.state.disable_disp = self.disable_disp.GetValue() 
    658650        self.SetupScrolling() 
    659  
     651     
    660652    def onResetModel(self, event): 
    661653        """ 
     
    675667            previous_state = self.saved_states[name] 
    676668            ## reset state of checkbox,textcrtl  and  regular parameters value 
    677  
     669             
    678670            self.reset_page(previous_state) 
    679671        self.state.m_name = self.m_name 
    680672        self.Show(True) 
    681  
     673                
    682674    def on_preview(self, event): 
    683675        """ 
     
    688680        # get the report dialog 
    689681        self.state.report(images, canvases) 
    690  
     682         
    691683    def on_save(self, event): 
    692684        """ 
     
    701693                        self._manager.parent._default_save_location 
    702694        dlg = wx.FileDialog(self, "Choose a file", self._default_save_location, 
    703                             self.window_caption, "*.fitv", wx.SAVE) 
     695                                        self.window_caption, "*.fitv", wx.SAVE) 
    704696 
    705697        if dlg.ShowModal() == wx.ID_OK: 
    706698            path = dlg.GetPath() 
    707699            self._default_save_location = os.path.dirname(path) 
    708             self._manager.parent._default_save_location = \ 
    709                                 self._default_save_location 
     700            self._manager.parent._default_save_location =\ 
     701                                 self._default_save_location 
    710702        else: 
    711703            return None 
     
    717709        self._manager.save_fit_state(filepath=fName, fitstate=new_state) 
    718710        return new_state 
    719  
     711     
    720712    def on_copy(self, event): 
    721713        """ 
     
    734726            wx.CallAfter(self.get_copy) 
    735727 
    736  
     728         
    737729    def on_paste(self, event): 
    738730        """ 
     
    746738        # messages depending on the flag 
    747739        #self._copy_info(True) 
    748  
     740         
    749741    def _copy_info(self, flag): 
    750742        """ 
    751743        Send event dpemding on flag 
    752  
     744         
    753745        : Param flag: flag that distinguish event 
    754746        """ 
     
    766758        # inform msg to wx 
    767759        wx.PostEvent(self._manager.parent, 
    768                      StatusEvent(status=msg, info=infor)) 
    769  
     760                    StatusEvent(status=msg, info=infor)) 
     761         
    770762    def _get_time_stamp(self): 
    771763        """ 
     
    777769        current_date = str(month) + "/" + str(day) + "/" + str(year) 
    778770        return current_time, current_date 
    779  
     771       
    780772    def on_bookmark(self, event): 
    781773        """ 
     
    796788        name += "bookmarked at %s on %s" % (current_time, current_date) 
    797789        self.saved_states[name] = new_state 
    798  
     790         
    799791        ## Add item in the context menu 
    800792        msg = "Model saved at %s on %s" % (current_time, current_date) 
     
    802794        msg += " Saved! right click on this page to retrieve this model" 
    803795        wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    804  
    805         self.popUpMenu.Append(self.ID_BOOKMARK, name, str(msg)) 
    806         wx.EVT_MENU(self, self.ID_BOOKMARK, self.onResetModel) 
     796         
     797        id = wx.NewId() 
     798        self.popUpMenu.Append(id, name, str(msg)) 
     799        wx.EVT_MENU(self, id, self.onResetModel) 
    807800        wx.PostEvent(self._manager.parent, 
    808801                     AppendBookmarkEvent(title=name, 
    809802                                         hint=str(msg), 
    810803                                         handler=self._back_to_bookmark)) 
    811  
     804     
    812805    def _back_to_bookmark(self, event): 
    813806        """ 
     
    817810        self.onResetModel(event) 
    818811        self._draw_model() 
    819  
     812                 
    820813    def onSetFocus(self, evt): 
    821814        """ 
     
    824817        """ 
    825818        return 
    826  
     819     
    827820    def read_file(self, path): 
    828821        """ 
    829822        Read two columns file 
    830  
     823         
    831824        :param path: the path to the file to read 
    832  
     825         
    833826        """ 
    834827        try: 
     
    863856        """ 
    864857        return self.state.clone() 
    865  
     858     
    866859    def save_current_state(self): 
    867860        """ 
     
    873866            self.state.disp_list = copy.deepcopy(self.disp_list) 
    874867            self.state.model = self.model.clone() 
    875  
     868             
    876869            #model combobox: complex code because of mac's silent error 
    877870            if self.structurebox != None: 
     
    892885                self.state.categorycombobox = self.categorybox.\ 
    893886                GetString(cb_select) 
    894  
     887         
    895888        self.state.enable2D = copy.deepcopy(self.enable2D) 
    896889        self.state.values = copy.deepcopy(self.values) 
     
    909902            self.state.enable_disp = self.enable_disp.GetValue() 
    910903            self.state.disable_disp = self.disable_disp.GetValue() 
    911  
     904             
    912905        self.state.smearer = copy.deepcopy(self.current_smearer) 
    913906        if hasattr(self, "enable_smearer"): 
     
    924917        self.state.dxw = copy.deepcopy(self.dxw) 
    925918        self.state.slit_smearer = copy.deepcopy(self.slit_smearer.GetValue()) 
    926  
     919                   
    927920        if len(self._disp_obj_dict) > 0: 
    928921            for k, v in self._disp_obj_dict.iteritems(): 
     
    933926        ## save plotting range 
    934927        self._save_plotting_range() 
    935  
     928         
    936929        self.state.orientation_params = [] 
    937930        self.state.orientation_params_disp = [] 
     
    948941        self._copy_parameters_state(self.orientation_params_disp, 
    949942                                     self.state.orientation_params_disp) 
    950  
     943         
    951944        self._copy_parameters_state(self.parameters, self.state.parameters) 
    952945        self._copy_parameters_state(self.fittable_param, 
     
    955948        #save chisqr 
    956949        self.state.tcChi = self.tcChi.GetValue() 
    957  
     950         
    958951    def save_current_state_fit(self): 
    959952        """ 
     
    965958            self.state.disp_list = copy.deepcopy(self.disp_list) 
    966959            self.state.model = self.model.clone() 
    967  
     960             
    968961        self.state.enable2D = copy.deepcopy(self.enable2D) 
    969962        self.state.values = copy.deepcopy(self.values) 
     
    971964        ## save data 
    972965        self.state.data = copy.deepcopy(self.data) 
    973  
     966         
    974967        if hasattr(self, "enable_disp"): 
    975968            self.state.enable_disp = self.enable_disp.GetValue() 
    976969            self.state.disable_disp = self.disable_disp.GetValue() 
    977  
     970             
    978971        self.state.smearer = copy.deepcopy(self.current_smearer) 
    979972        if hasattr(self, "enable_smearer"): 
     
    982975            self.state.disable_smearer = \ 
    983976                                copy.deepcopy(self.disable_smearer.GetValue()) 
    984  
     977             
    985978        self.state.pinhole_smearer = \ 
    986979                                copy.deepcopy(self.pinhole_smearer.GetValue()) 
     
    1005998                for k, v in self._disp_obj_dict.iteritems(): 
    1006999                    self.state._disp_obj_dict[k] = v 
    1007  
     1000                         
    10081001            self.state.values = copy.deepcopy(self.values) 
    10091002            self.state.weights = copy.deepcopy(self.weights) 
    1010  
     1003            
    10111004        ## save plotting range 
    10121005        self._save_plotting_range() 
    1013  
     1006         
    10141007        ## save checkbutton state and txtcrtl values 
    10151008        self._copy_parameters_state(self.orientation_params, 
    1016                                     self.state.orientation_params) 
     1009                                     self.state.orientation_params) 
    10171010        self._copy_parameters_state(self.orientation_params_disp, 
    1018                                     self.state.orientation_params_disp) 
     1011                                     self.state.orientation_params_disp) 
    10191012        self._copy_parameters_state(self.parameters, self.state.parameters) 
    10201013        self._copy_parameters_state(self.fittable_param, 
    1021                                     self.state.fittable_param) 
     1014                                             self.state.fittable_param) 
    10221015        self._copy_parameters_state(self.fixed_param, self.state.fixed_param) 
    1023  
     1016     
    10241017    def check_invalid_panel(self): 
    10251018        """ 
     
    10321025            wx.MessageBox(msg, 'Info') 
    10331026            return  True 
    1034  
     1027         
    10351028    def set_model_state(self, state): 
    10361029        """ 
     
    10391032        self.disp_cb_dict = state.disp_cb_dict 
    10401033        self.disp_list = state.disp_list 
    1041  
     1034       
    10421035        ## set the state of the radio box 
    10431036        #self.shape_rbutton.SetValue(state.shape_rbutton) 
     
    10451038        #self.struct_rbutton.SetValue(state.struct_rbutton) 
    10461039        #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1047  
     1040         
    10481041        ## fill model combobox 
    10491042        self._show_combox_helper() 
     
    10591052                    category_pos = int(ind_cat) 
    10601053                    break 
    1061  
     1054             
    10621055        self.categorybox.Select(category_pos) 
    10631056        try: 
     
    10711064                    formfactor_pos = int(ind_form) 
    10721065                    break 
    1073  
     1066             
    10741067        self.formfactorbox.Select(formfactor_pos) 
    1075  
     1068         
    10761069        try: 
    10771070            # to support older version 
     
    10841077                    structfactor_pos = int(ind_struct) 
    10851078                    break 
    1086  
     1079                 
    10871080        self.structurebox.SetSelection(structfactor_pos) 
    1088  
     1081         
    10891082        if state.multi_factor != None: 
    10901083            self.multifactorbox.SetSelection(state.multi_factor) 
    1091  
     1084             
    10921085        ## reset state of checkbox,textcrtl  and  regular parameters value 
    10931086        self._reset_parameters_state(self.orientation_params_disp, 
     
    11011094        self.enable_disp.SetValue(state.enable_disp) 
    11021095        self.disable_disp.SetValue(state.disable_disp) 
    1103  
     1096         
    11041097        if hasattr(self, "disp_box") and self.disp_box != None: 
    11051098            self.disp_box.SetSelection(state.disp_box) 
     
    11091102 
    11101103            self._set_dipers_Param(event=None) 
    1111  
     1104        
    11121105            if name == "ArrayDispersion": 
    1113  
     1106                 
    11141107                for item in self.disp_cb_dict.keys(): 
    1115  
     1108                     
    11161109                    if hasattr(self.disp_cb_dict[item], "SetValue"): 
    11171110                        self.disp_cb_dict[item].SetValue(\ 
    11181111                                                    state.disp_cb_dict[item]) 
    11191112                        # Create the dispersion objects 
    1120                         from sas.models.dispersion_models import ArrayDispersion 
     1113                        #from sas.models.dispersion_models import ArrayDispersion 
     1114                        from sasmodels.weights import ArrayDispersion 
    11211115                        disp_model = ArrayDispersion() 
    11221116                        if hasattr(state, "values") and \ 
     
    11291123                            else: 
    11301124                                self._reset_dispersity() 
    1131  
     1125                         
    11321126                        self._disp_obj_dict[item] = disp_model 
    11331127                        # Set the new model as the dispersion object 
    11341128                        #for the selected parameter 
    11351129                        self.model.set_dispersion(item, disp_model) 
    1136  
     1130                     
    11371131                        self.model._persistency_dict[item] = \ 
    11381132                                                [state.values, state.weights] 
    1139  
     1133                     
    11401134            else: 
    11411135                keys = self.model.getParamList() 
     
    11551149        self.pinhole_smearer.SetValue(state.pinhole_smearer) 
    11561150        self.slit_smearer.SetValue(state.slit_smearer) 
    1157  
     1151         
    11581152        self.dI_noweight.SetValue(state.dI_noweight) 
    11591153        self.dI_didata.SetValue(state.dI_didata) 
    11601154        self.dI_sqrdata.SetValue(state.dI_sqrdata) 
    11611155        self.dI_idata.SetValue(state.dI_idata) 
    1162  
     1156         
    11631157        ## we have two more options for smearing 
    11641158        if self.pinhole_smearer.GetValue(): 
     
    11661160        elif self.slit_smearer.GetValue(): 
    11671161            self.onSlitSmear(event=None) 
    1168  
     1162        
    11691163        ## reset state of checkbox,textcrtl  and dispersity parameters value 
    11701164        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    11711165        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    1172  
     1166         
    11731167        ## draw the model with previous parameters value 
    11741168        self._onparamEnter_helper() 
     
    11781172        self._lay_out() 
    11791173        self.Refresh() 
    1180  
     1174         
    11811175    def reset_page_helper(self, state): 
    11821176        """ 
    11831177        Use page_state and change the state of existing page 
    1184  
     1178         
    11851179        :precondition: the page is already drawn or created 
    1186  
     1180         
    11871181        :postcondition: the state of the underlying data change as well as the 
    11881182            state of the graphic interface 
     
    12101204        else: 
    12111205            self.set_data(data) 
    1212  
     1206             
    12131207        self.enable2D = state.enable2D 
    12141208        try: 
     
    12201214        self.disp_cb_dict = state.disp_cb_dict 
    12211215        self.disp_list = state.disp_list 
    1222  
     1216       
    12231217        ## set the state of the radio box 
    12241218        #self.shape_rbutton.SetValue(state.shape_rbutton) 
     
    12261220        #self.struct_rbutton.SetValue(state.struct_rbutton) 
    12271221        #self.plugin_rbutton.SetValue(state.plugin_rbutton) 
    1228  
     1222         
    12291223        ## fill model combobox 
    12301224        self._show_combox_helper() 
     
    12401234                    category_pos = int(ind_cat) 
    12411235                    break 
    1242  
     1236             
    12431237        self.categorybox.Select(category_pos) 
    12441238        self._show_combox(None) 
     
    12531247                    formfactor_pos = int(ind_form) 
    12541248                    break 
    1255  
     1249             
    12561250        self.formfactorbox.Select(formfactor_pos) 
    1257  
     1251         
    12581252        try: 
    12591253            # to support older version 
     
    12661260                    structfactor_pos = int(ind_struct) 
    12671261                    break 
    1268  
     1262             
    12691263        self.structurebox.SetSelection(structfactor_pos) 
    12701264 
     
    12741268        #draw the panel according to the new model parameter 
    12751269        self._on_select_model(event=None) 
    1276  
     1270             
    12771271        # take care of 2D button 
    12781272        if data == None and self.model_view.IsEnabled(): 
     
    12811275            else: 
    12821276                self.model_view.SetLabel("1D Mode") 
    1283          
     1277                 
    12841278        ## set the select all check box to the a given state 
    12851279        self.cb1.SetValue(state.cb1) 
    1286  
     1280      
    12871281        ## reset state of checkbox,textcrtl  and  regular parameters value 
    12881282        self._reset_parameters_state(self.orientation_params_disp, 
     
    13231317            self.dI_sqrdata.SetValue(False) 
    13241318            self.dI_idata.SetValue(False) 
    1325  
     1319  
    13261320        ## we have two more options for smearing 
    13271321        if self.pinhole_smearer.GetValue(): 
     
    13391333                self.smear_slit_height.SetValue(str(self.dxl)) 
    13401334            if self.dxw != None: 
    1341                 self.smear_slit_width.SetValue(str(self.dxw)) 
     1335                self.smear_slit_width.SetValue(str(self.dxw))   
    13421336            else: 
    1343                 self.smear_slit_width.SetValue('') 
     1337                self.smear_slit_width.SetValue('')   
    13441338            self.onSlitSmear(event=None) 
    1345  
     1339         
    13461340        ## reset state of checkbox,textcrtl  and dispersity parameters value 
    13471341        self._reset_parameters_state(self.fittable_param, state.fittable_param) 
    13481342        self._reset_parameters_state(self.fixed_param, state.fixed_param) 
    1349  
     1343         
    13501344        ## draw the model with previous parameters value 
    13511345        self._onparamEnter_helper() 
     
    13541348        ## reset context menu items 
    13551349        self._reset_context_menu() 
    1356  
     1350         
    13571351        ## set the value of the current state to the state given as parameter 
    13581352        self.state = state.clone() 
    13591353        self.state.m_name = self.m_name 
    1360  
     1354     
    13611355    def _reset_page_disp_helper(self, state): 
    13621356        """ 
     
    13731367        self.values = copy.deepcopy(state.values) 
    13741368        self.weights = copy.deepcopy(state.weights) 
    1375  
     1369         
    13761370        for key, disp in state._disp_obj_dict.iteritems(): 
    13771371            # From saved file, disp_model can not be sent in model obj. 
     
    13791373            if disp.__class__.__name__ == 'str': 
    13801374                disp_model = None 
    1381                 com_str = "from sas.models.dispersion_models " 
     1375                #com_str = "from sas.models.dispersion_models " 
     1376                com_str = "from sasmodels.weights " 
    13821377                com_str += "import %s as disp_func \ndisp_model = disp_func()" 
    13831378                exec com_str % disp 
     
    14201415                        except: 
    14211416                            logging.error(sys.exc_info()[1]) 
    1422  
     1417     
    14231418        # Make sure the check box updated when all checked 
    14241419        if self.cb1.GetValue(): 
    14251420            self.select_all_param(None) 
    1426  
     1421       
    14271422    def _selectDlg(self): 
    14281423        """ 
    1429         open a dialog file to selected the customized dispersity 
     1424        open a dialog file to selected the customized dispersity  
    14301425        """ 
    14311426        if self.parent != None: 
     
    14331428                        self._manager.parent.get_save_location() 
    14341429        dlg = wx.FileDialog(self, "Choose a weight file", 
    1435                             self._default_save_location, "", 
    1436                             "*.*", wx.OPEN) 
     1430                                self._default_save_location, "", 
     1431                                "*.*", wx.OPEN) 
    14371432        path = None 
    14381433        if dlg.ShowModal() == wx.ID_OK: 
     
    14451440        reset the context menu 
    14461441        """ 
    1447         ids = iter(self._id_pool)  # Reusing ids for context menu 
    14481442        for name, _ in self.state.saved_states.iteritems(): 
    14491443            self.number_saved_state += 1 
    14501444            ## Add item in the context menu 
    1451             wx_id = ids.next() 
     1445            id = wx.NewId() 
    14521446            msg = 'Save model and state %g' % self.number_saved_state 
    1453             self.popUpMenu.Append(wx_id, name, msg) 
    1454             wx.EVT_MENU(self, wx_id, self.onResetModel) 
    1455  
     1447            self.popUpMenu.Append(id, name, msg) 
     1448            wx.EVT_MENU(self, id, self.onResetModel) 
     1449     
    14561450    def _reset_plotting_range(self, state): 
    14571451        """ 
     
    14721466        self.state.formfactorcombobox = self.formfactorbox.GetLabel() 
    14731467        self.state.categorycombobox = self.categorybox.GetLabel() 
    1474  
     1468        
    14751469        ## post state to fit panel 
    14761470        event = PageInfoEvent(page=self) 
    14771471        wx.PostEvent(self.parent, event) 
    1478  
     1472         
    14791473    def _save_plotting_range(self): 
    14801474        """ 
     
    14841478        self.state.qmax = self.qmax_x 
    14851479        self.state.npts = self.npts_x 
    1486  
     1480             
    14871481    def _onparamEnter_helper(self): 
    14881482        """ 
     
    15011495            try: 
    15021496                is_modified = self._check_value_enter(self.fittable_param, 
    1503                                                       is_modified) 
     1497                                                     is_modified) 
    15041498                is_modified = self._check_value_enter(self.fixed_param, 
    15051499                                                      is_modified) 
     
    15211515                    self.qmax_x = tempmax 
    15221516                    is_modified = True 
    1523  
     1517             
    15241518                if is_2Ddata: 
    15251519                    # set mask 
    15261520                    is_modified = self._validate_Npts() 
    1527  
     1521                     
    15281522            else: 
    15291523                self.fitrange = False 
    1530  
     1524                 
    15311525            if not self.data.is_data: 
    15321526                is_modified = True 
     
    15481542                self.Refresh() 
    15491543        return is_modified 
    1550  
     1544     
    15511545    def _update_paramv_on_fit(self): 
    15521546        """ 
     
    15731567            self._check_value_enter(self.parameters, is_modified) 
    15741568 
    1575             # If qmin and qmax have been modified, update qmin and qmax and 
     1569            # If qmin and qmax have been modified, update qmin and qmax and  
    15761570            # Here we should check whether the boundaries have been modified. 
    1577             # If qmin and qmax have been modified, update qmin and qmax and 
     1571            # If qmin and qmax have been modified, update qmin and qmax and  
    15781572            # set the is_modified flag to True 
    15791573            self.fitrange = self._validate_qrange(self.qmin, self.qmax) 
     
    16021596                                                  qmax=float(self.qmax_x), 
    16031597                                                  enable_smearer=enable_smearer, 
    1604                                                   draw=False) 
     1598                                                      draw=False) 
    16051599                elif not self._is_2D(): 
    16061600                    enable_smearer = not self.disable_smearer.GetValue() 
     
    16111605                                              qmax=float(self.qmax_x), 
    16121606                                              enable_smearer=enable_smearer, 
    1613                                               draw=False) 
     1607                                                 draw=False) 
    16141608                    if self.data != None: 
    16151609                        index_data = ((self.qmin_x <= self.data.x) & \ 
     
    16471641            msg += " model or Fitting range is not valid!!!  " 
    16481642            wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    1649  
     1643         
    16501644        try: 
    16511645            self.save_current_state() 
    16521646        except: 
    16531647            logging.error(sys.exc_info()[1]) 
    1654  
     1648    
    16551649        return flag 
    1656  
     1650                
    16571651    def _is_modified(self, is_modified): 
    16581652        """ 
     
    16601654        """ 
    16611655        return is_modified 
    1662  
     1656                        
    16631657    def _reset_parameters_state(self, listtorestore, statelist): 
    16641658        """ 
     
    16991693                item_page[5].Show(item_page_info[5][0]) 
    17001694                item_page[5].SetValue(item_page_info[5][1]) 
    1701  
     1695                 
    17021696            if item_page[6] != None: 
    17031697                ## show of hide the text crtl for fitting error 
    17041698                item_page[6].Show(item_page_info[6][0]) 
    17051699                item_page[6].SetValue(item_page_info[6][1]) 
    1706  
     1700                     
    17071701    def _reset_strparam_state(self, listtorestore, statelist): 
    17081702        """ 
     
    17131707 
    17141708        listtorestore = copy.deepcopy(statelist) 
    1715  
     1709         
    17161710        for j in range(len(listtorestore)): 
    17171711            item_page = listtorestore[j] 
    17181712            item_page_info = statelist[j] 
    17191713            ##change the state of the check box for simple parameters 
    1720  
     1714             
    17211715            if item_page[0] != None: 
    17221716                item_page[0].SetValue(format_number(item_page_info[0], True)) 
     
    17301724                item_page[2].SetValue(selection) 
    17311725                self.model.setParam(param_name, selection) 
    1732  
     1726                                       
    17331727    def _copy_parameters_state(self, listtocopy, statelist): 
    17341728        """ 
    17351729        copy the state of button 
    1736  
     1730         
    17371731        :param listtocopy: the list of check button to copy 
    17381732        :param statelist: list of state object to store the current state 
    1739  
     1733         
    17401734        """ 
    17411735        if len(listtocopy) == 0: 
    17421736            return 
    1743  
     1737        
    17441738        for item in listtocopy: 
    1745  
     1739   
    17461740            checkbox_state = None 
    17471741            if item[0] != None: 
     
    17591753                error_value = item[4].GetValue() 
    17601754                error_state = item[4].IsShown() 
    1761  
     1755                 
    17621756            min_value = None 
    17631757            min_state = None 
     
    17651759                min_value = item[5].GetValue() 
    17661760                min_state = item[5].IsShown() 
    1767  
     1761                 
    17681762            max_value = None 
    17691763            max_state = None 
     
    17741768            if item[7] != None: 
    17751769                unit = item[7].GetLabel() 
    1776  
     1770                
    17771771            statelist.append([checkbox_state, parameter_name, parameter_value, 
    17781772                              static_text, [error_state, error_value], 
    17791773                              [min_state, min_value], 
    17801774                              [max_state, max_value], unit]) 
    1781  
    1782  
     1775            
     1776                 
    17831777    def _draw_model(self, update_chisqr=True, source='model'): 
    17841778        """ 
     
    17861780        The method will use the data member from the model page 
    17871781        to build a call to the fitting perspective manager. 
    1788  
     1782         
    17891783        :param chisqr: update chisqr value [bool] 
    17901784        """ 
    17911785        wx.CallAfter(self._draw_model_after, update_chisqr, source) 
    1792  
     1786         
    17931787    def _draw_model_after(self, update_chisqr=True, source='model'): 
    17941788        """ 
     
    17961790        The method will use the data member from the model page 
    17971791        to build a call to the fitting perspective manager. 
    1798  
     1792         
    17991793        :param chisqr: update chisqr value [bool] 
    18001794        """ 
     
    18241818                                    source='model', 
    18251819                                    weight=weight) 
    1826  
     1820        
    18271821    def _on_show_sld(self, event=None): 
    18281822        """ 
     
    18391833        sld_data.name = 'SLD' 
    18401834        sld_data.axes = self.sld_axes 
    1841         self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, 
    1842                               id=wx.ID_ANY) 
     1835        self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id=-1) 
    18431836        self.panel.ShowModal() 
    1844  
     1837         
    18451838    def _set_multfactor_combobox(self, multiplicity=10): 
    18461839        """ 
     
    18521845            self.multifactorbox.Append(str(idx), int(idx)) 
    18531846        self._hide_multfactor_combobox() 
    1854  
     1847         
    18551848    def _show_multfactor_combobox(self): 
    18561849        """ 
     
    18621855        if not self.multifactorbox.IsShown(): 
    18631856            self.multifactorbox.Show(True) 
    1864  
     1857              
    18651858    def _hide_multfactor_combobox(self): 
    18661859        """ 
     
    18721865        if self.multifactorbox.IsShown(): 
    18731866            self.multifactorbox.Hide() 
    1874  
     1867     
    18751868    def formfactor_combo_init(self): 
    18761869        """ 
     
    18781871        """ 
    18791872        self._show_combox(None) 
    1880  
     1873                 
    18811874    def _show_combox_helper(self): 
    18821875        """ 
     
    19111904                         StatusEvent(status=msg, info="error")) 
    19121905        self._populate_box(self.formfactorbox, m_list) 
    1913  
    1914     def _on_modify_cat(self, event=None): 
     1906     
     1907    def _on_modify_cat(self, event=None):   
    19151908        """ 
    19161909        Called when category manager is opened 
    19171910        """ 
    1918         self._manager.parent.on_category_panel(event) 
    1919  
     1911        self._manager.parent.on_category_panel(event)   
     1912         
    19201913    def _show_combox(self, event=None): 
    19211914        """ 
     
    19311924        self.Layout() 
    19321925        self.Refresh() 
    1933  
     1926   
    19341927    def _populate_box(self, combobox, list): 
    19351928        """ 
    19361929        fill combox box with dict item 
    1937  
     1930         
    19381931        :param list: contains item to fill the combox 
    19391932            item must model class 
     
    19441937            name = model.__class__.__name__ 
    19451938            if models.__name__ != "NoStructure": 
    1946                 if hasattr(model, "name"): 
     1939                if hasattr(model, "oldname"): 
     1940                    name = model.oldname 
     1941                elif hasattr(model, "name"): 
    19471942                    name = model.name 
    19481943                mlist.append((name, models)) 
    1949  
     1944                 
    19501945        # Sort the models 
    19511946        mlist_sorted = sorted(mlist) 
     
    19531948            combobox.Append(item[0], item[1]) 
    19541949        return 0 
    1955  
     1950     
    19561951    def _onQrangeEnter(self, event): 
    19571952        """ 
    19581953        Check validity of value enter in the Q range field 
    1959  
     1954         
    19601955        """ 
    19611956        tcrtl = event.GetEventObject() 
     
    20102005            self.create_default_data() 
    20112006        self._draw_model() 
    2012  
     2007                    
    20132008    def _theory_qrange_enter(self, event): 
    20142009        """ 
    20152010        Check validity of value enter in the Q range field 
    20162011        """ 
    2017  
     2012         
    20182013        tcrtl = event.GetEventObject() 
    20192014        #Clear msg if previously shown. 
     
    20672062        self.create_default_data() 
    20682063        self._draw_model() 
    2069  
     2064                    
    20702065    def _on_select_model_helper(self): 
    20712066        """ 
     
    20932088            self.structurebox.Enable() 
    20942089            self.text2.Enable() 
    2095  
     2090             
    20962091        if form_factor != None: 
    20972092            # set multifactor for Mutifunctional models 
     
    21102105                    # default value 
    21112106                    m_id = 1 
    2112  
     2107                     
    21132108                self.multi_factor = self.multifactorbox.GetClientData(m_id) 
    21142109                if self.multi_factor == None: 
     
    21382133            self.show_sld_button.Hide() 
    21392134            self.multi_factor = None 
    2140  
     2135               
    21412136        s_id = self.structurebox.GetCurrentSelection() 
    21422137        struct_factor = self.structurebox.GetClientData(s_id) 
    2143  
     2138         
    21442139        if  struct_factor != None: 
    21452140            from sas.models.MultiplicationModel import MultiplicationModel 
     
    21562151        # check if model has magnetic parameters 
    21572152        if len(self.model.magnetic_params) > 0: 
    2158             self._has_magnetic = True 
     2153            self._has_magnetic = True  
    21592154        else: 
    2160             self._has_magnetic = False 
     2155            self._has_magnetic = False   
    21612156        ## post state to fit panel 
    21622157        self.state.parameters = [] 
     
    21682163        self.on_set_focus(None) 
    21692164        self.Layout() 
    2170  
     2165         
    21712166    def _validate_qrange(self, qmin_ctrl, qmax_ctrl): 
    21722167        """ 
    21732168        Verify that the Q range controls have valid values 
    21742169        and that Qmin < Qmax. 
    2175  
     2170         
    21762171        :param qmin_ctrl: text control for Qmin 
    21772172        :param qmax_ctrl: text control for Qmax 
    2178  
     2173         
    21792174        :return: True is the Q range is value, False otherwise 
    2180  
     2175         
    21812176        """ 
    21822177        qmin_validity = check_float(qmin_ctrl) 
     
    22022197                return False 
    22032198        return True 
    2204  
     2199     
    22052200    def _validate_Npts(self): 
    22062201        """ 
     
    22372232                self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
    22382233                self.fitrange = True 
    2239  
     2234             
    22402235        return flag 
    22412236 
     
    22722267                self.Npts_fit.SetValue(str(len(index_data[index_data == True]))) 
    22732268                self.fitrange = True 
    2274  
     2269             
    22752270        return flag 
    2276  
     2271     
    22772272    def _check_value_enter(self, list, modified): 
    22782273        """ 
     
    22962291            #try: 
    22972292            name = str(item[1]) 
    2298  
     2293             
    22992294            if string.find(name, ".npts") == -1 and \ 
    23002295                                        string.find(name, ".nsigmas") == -1: 
     
    23022297                param_min = None 
    23032298                param_max = None 
    2304  
     2299                
    23052300                ## check minimun value 
    23062301                if item[5] != None and item[5] != "": 
     
    23112306                                if numpy.isfinite(param_min): 
    23122307                                    item[2].SetValue(format_number(param_min)) 
    2313  
     2308                             
    23142309                            item[5].SetBackgroundColour(wx.WHITE) 
    23152310                            item[2].SetBackgroundColour(wx.WHITE) 
    2316  
     2311                                            
    23172312                        except: 
    23182313                            msg = "Wrong fit parameter range entered" 
     
    23292324                                if numpy.isfinite(param_max): 
    23302325                                    item[2].SetValue(format_number(param_max)) 
    2331  
     2326                             
    23322327                            item[6].SetBackgroundColour(wx.WHITE) 
    23332328                            item[2].SetBackgroundColour(wx.WHITE) 
     
    23382333                            raise ValueError, msg 
    23392334                        is_modified = True 
    2340  
     2335                 
    23412336                if param_min != None and param_max != None: 
    23422337                    if not self._validate_qrange(item[5], item[6]): 
     
    23452340                        wx.PostEvent(self._manager.parent, 
    23462341                                     StatusEvent(status=msg)) 
    2347  
     2342                 
    23482343                if name in self.model.details.keys(): 
    23492344                    self.model.details[name][1:3] = param_min, param_max 
     
    23662361                msg = "Wrong Fit parameter value entered " 
    23672362                wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 
    2368  
     2363                 
    23692364        return is_modified 
    2370  
     2365         
    23712366    def _set_dipers_Param(self, event): 
    23722367        """ 
     
    23872382 
    23882383        self._reset_dispersity() 
    2389  
     2384     
    23902385        if self.model == None: 
    23912386            self.model_disp.Hide() 
     
    23952390        if self.enable_disp.GetValue(): 
    23962391            ## layout for model containing no dispersity parameters 
    2397  
     2392             
    23982393            self.disp_list = self.model.getDispParamList() 
    2399  
     2394              
    24002395            if len(self.disp_list) == 0 and len(self.disp_cb_dict) == 0: 
    24012396                self._layout_sizer_noDipers() 
     
    24052400        else: 
    24062401            self.sizer4_4.Clear(True) 
    2407  
     2402             
    24082403        ## post state to fit panel 
    24092404        self.save_current_state() 
     
    24132408        #draw the model with the current dispersity 
    24142409        self._draw_model() 
    2415         ## Need to use FitInside again here to replace the next four lines. 
    2416         ## Otherwised polydispersity off does not resize the scrollwindow.  
    2417         ## PDB Nov 28, 2015 
    2418         self.FitInside() 
    2419 #        self.sizer4_4.Layout() 
    2420 #        self.sizer5.Layout() 
    2421 #        self.Layout() 
    2422 #        self.Refresh() 
    2423  
     2410        self.sizer4_4.Layout() 
     2411        self.sizer5.Layout() 
     2412        self.Layout() 
     2413        self.Refresh() 
     2414           
    24242415    def _layout_sizer_noDipers(self): 
    24252416        """ 
     
    24312422        self.fixed_param = [] 
    24322423        self.orientation_params_disp = [] 
    2433  
     2424         
    24342425        self.sizer4_4.Clear(True) 
    24352426        text = "No polydispersity available for this model" 
    2436         model_disp = wx.StaticText(self, wx.ID_ANY, text) 
     2427        model_disp = wx.StaticText(self, -1, text) 
    24372428        self.sizer4_4.Add(model_disp, (iy, ix), (1, 1), 
    24382429                          wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
    24392430        self.sizer4_4.Layout() 
    24402431        self.sizer4.Layout() 
    2441  
     2432     
    24422433    def _reset_dispersity(self): 
    24432434        """ 
     
    24522443                if item in self.param_toFit: 
    24532444                    self.param_toFit.remove(item) 
    2454  
     2445          
    24552446        self.fittable_param = [] 
    24562447        self.fixed_param = [] 
     
    24582449        self.values = {} 
    24592450        self.weights = {} 
    2460  
    2461         from sas.models.dispersion_models import GaussianDispersion 
     2451       
     2452        #from sas.models.dispersion_models import GaussianDispersion 
     2453        from sasmodels.weights import GaussianDispersion 
    24622454        if len(self.disp_cb_dict) == 0: 
    24632455            self.save_current_state() 
     
    24702462                # Go back to Gaussian model (with 0 pts) 
    24712463                disp_model = GaussianDispersion() 
    2472  
     2464                
    24732465                self._disp_obj_dict[p] = disp_model 
    24742466                # Set the new model as the dispersion object 
     
    24832475        self.Layout() 
    24842476        self.Refresh() 
    2485  
     2477                   
    24862478    def _on_select_Disp(self, event): 
    24872479        """ 
     
    24962488        event = PageInfoEvent(page=self) 
    24972489        wx.PostEvent(self.parent, event) 
    2498  
     2490         
    24992491        self.sizer4_4.Layout() 
    25002492        self.sizer4.Layout() 
    25012493        self.SetupScrolling() 
    2502  
     2494     
    25032495    def _on_disp_func(self, event=None): 
    25042496        """ 
    25052497        Select a distribution function for the polydispersion 
    2506  
     2498         
    25072499        :Param event: ComboBox event 
    25082500        """ 
     
    25202512            disp_name = disp_box.GetValue() 
    25212513            dispersity = disp_box.GetClientData(selection) 
    2522  
     2514     
    25232515            #disp_model =  GaussianDispersion() 
    25242516            disp_model = dispersity() 
     
    25382530                self.model.set_dispersion(param_name, disp_model) 
    25392531                self.state._disp_obj_dict[name1] = disp_model 
    2540  
     2532  
    25412533                value1 = str(format_number(self.model.getParam(name1), True)) 
    25422534                value2 = str(format_number(self.model.getParam(name2))) 
     
    25662558            for item in self.fixed_param: 
    25672559                if item[1] == name2: 
    2568                     item[2].SetValue(value2) 
     2560                    item[2].SetValue(value2)  
    25692561                    # Disable Npts for array 
    25702562                    if disp_name.lower() == "array": 
     
    25792571                    else: 
    25802572                        item[2].Enable() 
    2581  
     2573                 
    25822574            # Make sure the check box updated when all checked 
    25832575            if self.cb1.GetValue(): 
     
    26002592            wx.PostEvent(self._manager.parent, 
    26012593                         StatusEvent(status=msg, info="error")) 
    2602  
     2594         
    26032595    def _set_array_disp(self, name=None, disp=None): 
    26042596        """ 
    26052597        Set array dispersion 
    2606  
     2598         
    26072599        :param name: name of the parameter for the dispersion to be set 
    26082600        :param disp: the polydisperion object 
     
    26212613        self._default_save_location = os.path.dirname(path) 
    26222614        if self._manager != None: 
    2623             self._manager.parent._default_save_location = \ 
     2615            self._manager.parent._default_save_location =\ 
    26242616                             self._default_save_location 
    26252617 
    26262618        basename = os.path.basename(path) 
    26272619        values, weights = self.read_file(path) 
    2628  
     2620         
    26292621        # If any of the two arrays is empty, notify the user that we won't 
    26302622        # proceed 
     
    26392631                                    values=values, weights=weights) 
    26402632        return basename 
    2641  
     2633     
    26422634    def _set_array_disp_model(self, name=None, disp=None, 
    26432635                              values=[], weights=[]): 
    26442636        """ 
    26452637        Set array dispersion model 
    2646  
     2638         
    26472639        :param name: name of the parameter for the dispersion to be set 
    26482640        :param disp: the polydisperion object 
     
    26732665        self.state.model._persistency_dict[name.split('.')[0]] = \ 
    26742666                                        [values, weights] 
    2675  
     2667                                         
    26762668    def _del_array_values(self, name=None): 
    26772669        """ 
    26782670        Reset array dispersion 
    2679  
     2671         
    26802672        :param name: name of the parameter for the dispersion to be set 
    26812673        """ 
     
    26912683        except: 
    26922684            logging.error(sys.exc_info()[1]) 
    2693  
     2685                                             
    26942686    def _lay_out(self): 
    26952687        """ 
    26962688        returns self.Layout 
    2697  
     2689         
    26982690        :Note: Mac seems to like this better when self. 
    26992691            Layout is called after fitting. 
     
    27022694        self.Layout() 
    27032695        return 
    2704  
     2696     
    27052697    def _sleep4sec(self): 
    27062698        """ 
     
    27112703        if ON_MAC == True: 
    27122704            time.sleep(1) 
    2713  
     2705             
    27142706    def _find_polyfunc_selection(self, disp_func=None): 
    27152707        """ 
    27162708        FInd Comboox selection from disp_func 
    2717  
     2709         
    27182710        :param disp_function: dispersion distr. function 
    27192711        """ 
     
    27292721        except: 
    27302722            return 3 
    2731  
     2723                             
    27322724    def on_reset_clicked(self, event): 
    27332725        """ 
     
    27412733            flag = False 
    27422734            return 
    2743  
     2735             
    27442736        elif self.data.__class__.__name__ == "Data2D": 
    27452737            data_min = 0 
     
    27472739            y = max(math.fabs(self.data.ymin), math.fabs(self.data.ymax)) 
    27482740            self.qmin_x = data_min 
    2749             self.qmax_x = math.sqrt(x * x + y * y) 
     2741            self.qmax_x = math.sqrt(x*x + y*y) 
    27502742            #self.data.mask = numpy.ones(len(self.data.data),dtype=bool) 
    27512743            # check smearing 
     
    27572749                else: 
    27582750                    flag = True 
    2759  
     2751                     
    27602752        elif self.data == None: 
    27612753            self.qmin_x = _QMIN_DEFAULT 
     
    27632755            self.num_points = _NPTS_DEFAULT 
    27642756            self.state.npts = self.num_points 
    2765  
     2757             
    27662758        elif self.data.__class__.__name__ != "Data2D": 
    27672759            self.qmin_x = min(self.data.x) 
     
    27792771        else: 
    27802772            flag = False 
    2781  
     2773             
    27822774        if flag == False: 
    27832775            msg = "Cannot Plot :Must enter a number!!!  " 
     
    27962788        self.state.qmin = self.qmin_x 
    27972789        self.state.qmax = self.qmax_x 
    2798  
     2790         
    27992791        #reset the q range values 
    28002792        self._reset_plotting_range(self.state) 
    28012793        self._draw_model() 
    2802  
     2794         
    28032795    def select_log(self, event): 
    28042796        """ 
     
    28092801        """ 
    28102802        Get the images of the plots corresponding this panel for report 
    2811  
     2803         
    28122804        : return graphs: list of figures 
    28132805        : Need Move to guiframe 
     
    28332825                        # append to the list 
    28342826                        graphs.append(item2.figure) 
    2835                         canvases.append(item2.canvas) 
     2827                        canvases.append(item2.canvas)   
    28362828            except: 
    28372829                # Not for control panels 
     
    28642856            name = self.formfactorbox.GetValue() 
    28652857            _PageAnchor = '#' + name.lower() 
    2866             _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
     2858            _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, 
    28672859                                              _PageAnchor, name + " Help") 
    28682860        else: 
    2869             _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
    2870                                               "", "General Model Help") 
     2861            _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "", 
     2862                                                "General Model Help") 
    28712863 
    28722864 
     
    28832875        :param evt: on Description Button pressed event 
    28842876        """ 
    2885  
     2877         
    28862878        if self.model == None: 
    28872879            name = 'index.html' 
     
    28892881            name = self.formfactorbox.GetValue() 
    28902882 
    2891         msg = 'Model description:\n' 
     2883                msg = 'Model description:\n' 
    28922884        info = "Info" 
    28932885        if self.model != None: 
    28942886#                frame.Destroy() 
    2895             if str(self.model.description).rstrip().lstrip() == '': 
    2896                 msg += "Sorry, no information is available for this model." 
     2887                if str(self.model.description).rstrip().lstrip() == '': 
     2888                    msg += "Sorry, no information is available for this model." 
     2889                else: 
     2890                    msg += self.model.description + '\n' 
     2891                wx.MessageBox(msg, info) 
    28972892            else: 
    2898                 msg += self.model.description + '\n' 
    2899             wx.MessageBox(msg, info) 
    2900         else: 
    29012893            msg += "You must select a model to get information on this" 
    29022894            wx.MessageBox(msg, info) 
     
    29192911 
    29202912        _TreeLocation = "_images/M_angles_pic.bmp" 
    2921         _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 
     2913        _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "", 
    29222914                                          "Magnetic Angle Defintions") 
    29232915 
    2924     def _on_mag_help(self, event): 
     2916    def _on_mag_help(self, event):     
    29252917        """ 
    29262918        Bring up Magnetic Angle definition bmp image whenever the ? button 
     
    29392931 
    29402932        _TreeLocation = "user/perspectives/fitting/mag_help.html" 
    2941         _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 
     2933        _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "", 
    29422934                                          "Polarized Beam/Magnetc Help") 
    29432935 
    2944     def _on_mag_on(self, event): 
     2936    def _on_mag_on(self, event):     
    29452937        """ 
    29462938        Magnetic Parameters ON/OFF 
     
    29632955                    #reset mag value to zero fo safety 
    29642956                    self.model.setParam(key, 0.0) 
    2965  
    2966         self.Show(False) 
     2957                     
     2958        self.Show(False)     
    29672959        self.set_model_param_sizer(self.model) 
    29682960        #self._set_sizer_dispersion()  
     
    29702962        self.SetupScrolling() 
    29712963        self.Show(True) 
    2972  
     2964             
    29732965    def on_pd_help_clicked(self, event): 
    29742966        """ 
     
    29802972        webbrowser does not pass anything past the # to the browser when it is 
    29812973        running "file:///...." 
    2982  
     2974         
    29832975        :param evt: Triggers on clicking ? in polydispersity box 
    29842976        """ 
     
    29862978        _TreeLocation = "user/perspectives/fitting/pd_help.html" 
    29872979        _PageAnchor = "" 
    2988         _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 
     2980        _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, 
    29892981                                          _PageAnchor, "Polydispersity Help") 
    2990  
     2982         
    29912983    def on_left_down(self, event): 
    29922984        """ 
     
    30032995        # make event free 
    30042996        event.Skip() 
    3005  
     2997         
    30062998    def get_copy(self): 
    30072999        """ 
     
    30123004        self._copy_info(flag) 
    30133005        return flag 
    3014  
     3006             
    30153007    def get_copy_params(self): 
    30163008        """ 
     
    30203012        # Do it if params exist 
    30213013        if  self.parameters != []: 
    3022  
     3014             
    30233015            # go through the parameters 
    30243016            strings = self._get_copy_helper(self.parameters, 
    30253017                                           self.orientation_params) 
    30263018            content += strings 
    3027  
     3019             
    30283020            # go through the fittables 
    30293021            strings = self._get_copy_helper(self.fittable_param, 
     
    30353027                                           self.orientation_params_disp) 
    30363028            content += strings 
    3037  
     3029                 
    30383030            # go through the str params 
    30393031            strings = self._get_copy_helper(self.str_parameters, 
     
    30683060                content += param[1] #parameter name 
    30693061                content += tab 
    3070                 content += param[1] + "_err" 
     3062                content += param[1]+"_err" 
    30713063                content += tab 
    30723064 
     
    30763068            for param in self.parameters: 
    30773069                content += param[2].GetValue() #value 
    3078                 content += tab 
     3070                content +=tab 
    30793071                content += param[4].GetValue() #error 
    3080                 content += tab 
     3072                content +=tab 
    30813073 
    30823074            return content 
     
    31143106 
    31153107            for index, param in enumerate(self.parameters): 
    3116                 content += param[1].replace('_', '\_') #parameter name 
     3108                content += param[1].replace('_','\_') #parameter name 
    31173109                content += ' & ' 
    3118                 content += param[1].replace('_', '\_') + "\_err" 
    3119                 if index < len(self.parameters) - 1: 
     3110                content += param[1].replace('_','\_')+"\_err" 
     3111                if index < len(self.parameters)-1: 
    31203112                    content += ' & ' 
    31213113            content += '\\\\ \\hline' 
     
    31273119                content += ' & ' 
    31283120                content += param[4].GetValue() #parameter error 
    3129                 if index < len(self.parameters) - 1: 
     3121                if index < len(self.parameters)-1: 
    31303122                    content += ' & ' 
    31313123            content += '\\\\ \\hline' 
     
    31503142            return True 
    31513143        return None 
    3152  
     3144     
    31533145    def _get_copy_helper(self, param, orient_param): 
    31543146        """ 
    31553147        Helping get value and name of the params 
    3156  
     3148         
    31573149        : param param:  parameters 
    31583150        : param orient_param = oritational params 
     
    31713163            except: 
    31723164                logging.error(sys.exc_info()[1]) 
    3173  
     3165             
    31743166            # 2D 
    31753167            if self.data.__class__.__name__ == "Data2D": 
     
    31933185            # add to the content 
    31943186            if disfunc != '': 
    3195  
     3187                 
    31963188                disfunc = ',' + disfunc 
    31973189            # Need to support array func for copy/paste 
     
    32093201 
    32103202        return content 
    3211  
     3203    
    32123204    def get_clipboard(self): 
    32133205        """ 
     
    32293221            wx.TheClipboard.Close() 
    32303222        return text 
    3231  
     3223     
    32323224    def get_paste(self): 
    32333225        """ 
     
    32383230        self._copy_info(flag) 
    32393231        return flag 
    3240  
     3232         
    32413233    def get_paste_params(self, text=''): 
    32423234        """ 
     
    32673259                    val = [float(a_val) for a_val in array_values[1:]] 
    32683260                    weit = [float(a_weit) for a_weit in array_weights[1:]] 
    3269  
     3261                     
    32703262                    context[name].append(val) 
    32713263                    context[name].append(weit) 
     
    32903282            self._get_paste_helper(self.fixed_param, 
    32913283                                   self.orientation_params_disp, context) 
    3292  
     3284             
    32933285            # go through the str params 
    32943286            self._get_paste_helper(self.str_parameters, 
    32953287                                   self.orientation_params, context) 
    3296  
     3288                 
    32973289            return True 
    32983290        return None 
    3299  
     3291     
    33003292    def _get_paste_helper(self, param, orient_param, content): 
    33013293        """ 
    33023294        Helping set values of the params 
    3303  
     3295         
    33043296        : param param:  parameters 
    33053297        : param orient_param: oritational params 
     
    33293321                            fun_val = self.model.fun_list[content[name][1]] 
    33303322                            self.model.setParam(name, fun_val) 
    3331  
     3323                     
    33323324                    value = content[name][1:] 
    33333325                    self._paste_poly_help(item, value) 
     
    33753367                        if is_true != None: 
    33763368                            item[0].SetValue(is_true) 
    3377  
     3369                         
    33783370    def _paste_poly_help(self, item, value): 
    33793371        """ 
    33803372        Helps get paste for poly function 
    3381  
     3373         
    33823374        :param item: Gui param items 
    33833375        :param value: the values for parameter ctrols 
     
    34193411                                            [self.state.values, 
    34203412                                             self.state.weights] 
    3421  
     3413                          
    34223414            except: 
    34233415                logging.error(sys.exc_info()[1]) 
    34243416                print "Error in BasePage._paste_poly_help: %s" % \ 
    34253417                                        sys.exc_info()[1] 
    3426  
     3418     
    34273419    def _set_disp_array_cb(self, item): 
    34283420        """ 
     
    34383430        item[6].SetValue('') 
    34393431        item[6].Enable(False) 
    3440  
     3432         
    34413433    def update_pinhole_smear(self): 
    34423434        """ 
     
    34603452            if not os.path.isfile(categorization_file): 
    34613453                categorization_file = CategoryInstaller.get_default_file() 
    3462             cat_file = open(categorization_file, 'rb') 
     3454            cat_file = open(categorization_file, 'rb')                            
    34633455            self.master_category_dict = json.load(cat_file) 
    34643456            self._regenerate_model_dict() 
     
    34723464    def _regenerate_model_dict(self): 
    34733465        """ 
    3474         regenerates self.by_model_dict which has each model name as the 
     3466        regenerates self.by_model_dict which has each model name as the  
    34753467        key and the list of categories belonging to that model 
    34763468        along with the enabled mapping 
     
    34813473                self.by_model_dict[model].append(category) 
    34823474                self.model_enabled_dict[model] = enabled 
    3483  
     3475     
    34843476    def _populate_listbox(self): 
    34853477        """ 
     
    34933485        if not uncat_str in cat_list: 
    34943486            cat_list.append(uncat_str) 
    3495  
     3487         
    34963488        for category in cat_list: 
    34973489            if category != '': 
     
    35013493            self.categorybox.SetSelection(0) 
    35023494        else: 
    3503             self.categorybox.SetSelection(\ 
     3495            self.categorybox.SetSelection( \ 
    35043496                self.categorybox.GetSelection()) 
    35053497        #self._on_change_cat(None) 
     
    35213513 
    35223514        else: 
    3523             for (model, enabled) in sorted(self.master_category_dict[category], 
    3524                                       key=lambda name: name[0]): 
     3515            for (model,enabled) in sorted(self.master_category_dict[category], 
     3516                                      key = lambda name: name[0]): 
    35253517                if(enabled): 
    35263518                    self.model_box.Append(model) 
     
    35303522        fill sizer containing model info 
    35313523        """ 
    3532         # This should only be called once per fit tab 
    3533         #print "==== Entering _fill_model_sizer" 
    35343524        ##Add model function Details button in fitpanel. 
    35353525        ##The following 3 lines are for Mac. Let JHC know before modifying... 
     
    35373527        self.formfactorbox = None 
    35383528        self.multifactorbox = None 
    3539         self.mbox_description = wx.StaticBox(self, wx.ID_ANY, str(title)) 
     3529        self.mbox_description = wx.StaticBox(self, -1, str(title)) 
    35403530        boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL) 
    35413531        sizer_cat = wx.BoxSizer(wx.HORIZONTAL) 
    35423532        self.mbox_description.SetForegroundColour(wx.RED) 
    3543         wx_id = self._ids.next() 
    3544         self.model_func = wx.Button(self, wx_id, 'Help', size=(80, 23)) 
    3545         self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, 
    3546                              id=wx_id) 
     3533        id = wx.NewId() 
     3534        self.model_func = wx.Button(self, id, 'Help', size=(80, 23)) 
     3535        self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, id=id) 
    35473536        self.model_func.SetToolTipString("Full Model Function Help") 
    3548         wx_id = self._ids.next() 
    3549         self.model_help = wx.Button(self, wx_id, 'Description', size=(80, 23)) 
    3550         self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, 
    3551                              id=wx_id) 
     3537        id = wx.NewId() 
     3538        self.model_help = wx.Button(self, id, 'Description', size=(80, 23)) 
     3539        self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 
    35523540        self.model_help.SetToolTipString("Short Model Function Description") 
    3553         wx_id = self._ids.next() 
    3554         self.model_view = wx.Button(self, wx_id, "Show 2D", size=(80, 23)) 
    3555         self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=wx_id) 
     3541        id = wx.NewId() 
     3542        self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23)) 
     3543        self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=id) 
    35563544        hint = "toggle view of model from 1D to 2D  or 2D to 1D" 
    35573545        self.model_view.SetToolTipString(hint) 
    3558  
    3559         cat_set_box = wx.StaticBox(self, wx.ID_ANY, 'Category') 
     3546         
     3547        cat_set_box = wx.StaticBox(self, -1, 'Category') 
    35603548        sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL) 
    35613549        sizer_cat_box.SetMinSize((200, 50)) 
    3562         self.categorybox = wx.ComboBox(self, wx.ID_ANY, 
    3563                                        style=wx.CB_READONLY) 
    3564         self.categorybox.SetToolTip(wx.ToolTip("Select a Category/Type")) 
     3550        self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     3551        self.categorybox.SetToolTip( wx.ToolTip("Select a Category/Type") ) 
    35653552        self._populate_listbox() 
    3566         wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 
    3567         #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 
     3553        wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox) 
     3554        #self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes', 
    35683555        #                                     style=wx.RB_GROUP) 
    3569         #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 
     3556        #self.shape_indep_rbutton = wx.RadioButton(self, -1, 
    35703557        #                                          "Shape-Independent") 
    3571         #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    3572         #                                     "Structure Factor ") 
    3573         #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 
    3574         #                                     "Uncategorized") 
    3575  
     3558        #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 
     3559        #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized") 
     3560                 
    35763561        #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, 
    35773562        #                   id=self.shape_rbutton.GetId()) 
     
    35833568        #                    id=self.plugin_rbutton.GetId()) 
    35843569        #MAC needs SetValue 
    3585  
    3586         show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 
     3570         
     3571        show_cat_button = wx.Button(self, -1, "Modify") 
    35873572        cat_tip = "Modify model categories \n" 
    35883573        cat_tip += "(also accessible from the menu bar)." 
    3589         show_cat_button.SetToolTip(wx.ToolTip(cat_tip)) 
     3574        show_cat_button.SetToolTip( wx.ToolTip(cat_tip) ) 
    35903575        show_cat_button.Bind(wx.EVT_BUTTON, self._on_modify_cat) 
    35913576        sizer_cat_box.Add(self.categorybox, 1, wx.RIGHT, 3) 
    3592         sizer_cat_box.Add((10, 10)) 
     3577        sizer_cat_box.Add((10,10)) 
    35933578        sizer_cat_box.Add(show_cat_button) 
    35943579        #self.shape_rbutton.SetValue(True) 
    3595  
     3580       
    35963581        sizer_radiobutton = wx.GridSizer(2, 2, 5, 5) 
    35973582        #sizer_radiobutton.Add(self.shape_rbutton) 
    35983583        #sizer_radiobutton.Add(self.shape_indep_rbutton) 
    3599         sizer_radiobutton.Add((5, 5)) 
     3584        sizer_radiobutton.Add((5,5)) 
    36003585        sizer_radiobutton.Add(self.model_view, 1, wx.RIGHT, 5) 
    36013586        #sizer_radiobutton.Add(self.plugin_rbutton) 
     
    36093594        sizer_selection = wx.BoxSizer(wx.HORIZONTAL) 
    36103595        mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 
    3611  
    3612         self.text1 = wx.StaticText(self, wx.ID_ANY, "") 
    3613         self.text2 = wx.StaticText(self, wx.ID_ANY, "P(Q)*S(Q)") 
    3614         self.mutifactor_text = wx.StaticText(self, wx.ID_ANY, "No. of Shells: ") 
    3615         self.mutifactor_text1 = wx.StaticText(self, wx.ID_ANY, "") 
    3616         self.show_sld_button = wx.Button(self, wx.ID_ANY, "Show SLD Profile") 
     3596         
     3597        self.text1 = wx.StaticText(self, -1, "") 
     3598        self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)") 
     3599        self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ") 
     3600        self.mutifactor_text1 = wx.StaticText(self, -1, "") 
     3601        self.show_sld_button = wx.Button(self, -1, "Show SLD Profile") 
    36173602        self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 
    36183603 
    3619         self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    3620         self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 
     3604        self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     3605        self.formfactorbox.SetToolTip( wx.ToolTip("Select a Model") ) 
    36213606        if self.model != None: 
    36223607            self.formfactorbox.SetValue(self.model.name) 
    3623         self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    3624         self.multifactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
     3608        self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     3609        self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
    36253610        self.initialize_combox() 
    3626         wx.EVT_COMBOBOX(self.formfactorbox, wx.ID_ANY, self._on_select_model) 
    3627  
    3628         wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 
    3629         wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 
     3611        wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model) 
     3612 
     3613        wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model) 
     3614        wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model) 
    36303615        ## check model type to show sizer 
    36313616        if self.model != None: 
    36323617            print "_set_model_sizer_selection: disabled." 
    36333618            #self._set_model_sizer_selection(self.model) 
    3634  
     3619         
    36353620        sizer_selection.Add(self.text1) 
    36363621        sizer_selection.Add((10, 5)) 
     
    36403625        sizer_selection.Add((5, 5)) 
    36413626        sizer_selection.Add(self.structurebox) 
    3642  
     3627        
    36433628        mutifactor_selection.Add((13, 5)) 
    36443629        mutifactor_selection.Add(self.mutifactor_text) 
     
    36543639        boxsizer1.Add((10, 10)) 
    36553640        boxsizer1.Add(mutifactor_selection) 
    3656  
     3641         
    36573642        self._set_multfactor_combobox() 
    36583643        self.multifactorbox.SetSelection(1) 
     
    36603645        sizer.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 
    36613646        sizer.Layout() 
    3662  
     3647         
    36633648    def on_smear_helper(self, update=False): 
    36643649        """ 
    36653650        Help for onSmear if implemented 
    3666  
     3651         
    36673652        :param update: force or not to update 
    36683653        """ 
     
    36733658    def onSmear(self, event): 
    36743659        """ 
    3675         Create a smear object if implemented 
     3660        Create a smear object if implemented  
    36763661        """ 
    36773662    def onPinholeSmear(self, event): 
Note: See TracChangeset for help on using the changeset viewer.