Ignore:
Timestamp:
Oct 21, 2015 6:35:00 AM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
85130cb
Parents:
2d88fc4
Message:

clean up wx id handling in fitting perspective

File:
1 edited

Legend:

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

    racf8e4a5 r6f16e25  
    4646    ## Title to appear on top of the window 
    4747    window_caption = "Simultaneous Fit Page" 
    48  
    49     def __init__(self, parent, page_finder={}, id= -1, batch_on=False, 
     48    ID_SET_ALL = wx.NewId() 
     49    ID_REMOVE = wx.NewId() 
     50    ID_FIT = wx.NewId() 
     51    ID_ADD = wx.NewId() 
     52 
     53    def __init__(self, parent, page_finder={}, id= wx.ID_ANY, batch_on=False, 
    5054                     *args, **kwargs): 
    5155        ScrolledPanel.__init__(self, parent, id=id, 
     
    7882        self.model_cbox_left = None 
    7983        self.model_cbox_right = None 
    80         self.uid = wx.NewId() 
    8184        ## draw page 
    8285        self.define_page_structure() 
     
    294297 
    295298        self.sizer1.Clear(True) 
    296         box_description = wx.StaticBox(self, -1, "Fit Combinations") 
     299        box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Combinations") 
    297300        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    298301        sizer_title = wx.BoxSizer(wx.HORIZONTAL) 
     
    303306            msg += " Please load data and set up " 
    304307            msg += "at least two fit panels first..." 
    305             sizer_title.Add(wx.StaticText(self, -1, msg)) 
     308            sizer_title.Add(wx.StaticText(self, wx.ID_ANY, msg)) 
    306309        else: 
    307310            ## store model 
    308311            self._store_model() 
    309312 
    310             self.cb1 = wx.CheckBox(self, -1, 'Select all') 
     313            self.cb1 = wx.CheckBox(self, wx.ID_ANY, 'Select all') 
    311314            self.cb1.SetValue(False) 
    312315 
     
    370373        Show constraint fields 
    371374        """ 
    372         box_description = wx.StaticBox(self, -1, "Easy Setup ") 
     375        box_description = wx.StaticBox(self, wx.ID_ANY, "Easy Setup ") 
    373376        boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) 
    374377        sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 
    375         self.model_cbox_left = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     378        self.model_cbox_left = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    376379        self.model_cbox_left.Clear() 
    377         self.model_cbox_right = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     380        self.model_cbox_right = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    378381        self.model_cbox_right.Clear() 
    379         wx.EVT_COMBOBOX(self.model_cbox_left, -1, self._on_select_modelcb) 
    380         wx.EVT_COMBOBOX(self.model_cbox_right, -1, self._on_select_modelcb) 
    381         egal_txt = wx.StaticText(self, -1, " = ") 
    382         self.set_button = wx.Button(self, wx.NewId(), 'Set All') 
     382        wx.EVT_COMBOBOX(self.model_cbox_left, wx.ID_ANY, self._on_select_modelcb) 
     383        wx.EVT_COMBOBOX(self.model_cbox_right, wx.ID_ANY, self._on_select_modelcb) 
     384        egal_txt = wx.StaticText(self, wx.ID_ANY, " = ") 
     385        self.set_button = wx.Button(self, self.ID_SET_ALL, 'Set All') 
    383386        self.set_button.Bind(wx.EVT_BUTTON, self._on_set_all_equal, 
    384387                             id=self.set_button.GetId()) 
     
    399402        boxsizer.Add(self.model_cbox_left, 
    400403                             flag=wx.RIGHT | wx.EXPAND, border=10) 
    401         boxsizer.Add(wx.StaticText(self, -1, ".parameters"), 
     404        boxsizer.Add(wx.StaticText(self, wx.ID_ANY, ".parameters"), 
    402405                             flag=wx.RIGHT | wx.EXPAND, border=5) 
    403406        boxsizer.Add(egal_txt, flag=wx.RIGHT | wx.EXPAND, border=5) 
    404407        boxsizer.Add(self.model_cbox_right, 
    405408                             flag=wx.RIGHT | wx.EXPAND, border=10) 
    406         boxsizer.Add(wx.StaticText(self, -1, ".parameters"), 
     409        boxsizer.Add(wx.StaticText(self, wx.ID_ANY, ".parameters"), 
    407410                             flag=wx.RIGHT | wx.EXPAND, border=5) 
    408411        boxsizer.Add((20, -1)) 
     
    510513 
    511514        sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 
    512         model_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     515        model_cbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    513516        model_cbox.Clear() 
    514         param_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY, size=(100, -1),) 
     517        param_cbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY, size=(100, -1),) 
    515518        param_cbox.Hide() 
    516519 
     
    518521        self.param_cbox = param_cbox 
    519522 
    520         wx.EVT_COMBOBOX(param_cbox, -1, self._on_select_param) 
    521         self.ctl2 = wx.TextCtrl(self, -1) 
    522         egal_txt = wx.StaticText(self, -1, " = ") 
    523         self.btRemove = wx.Button(self, wx.NewId(), 'Remove') 
     523        wx.EVT_COMBOBOX(param_cbox, wx.ID_ANY, self._on_select_param) 
     524        self.ctl2 = wx.TextCtrl(self, wx.ID_ANY) 
     525        egal_txt = wx.StaticText(self, wx.ID_ANY, " = ") 
     526        self.btRemove = wx.Button(self, self.ID_REMOVE, 'Remove') 
    524527        self.btRemove.Bind(wx.EVT_BUTTON, self.onRemove, 
    525528                           id=self.btRemove.GetId()) 
     
    536539        self.model_cbox = model_cbox 
    537540 
    538         wx.EVT_COMBOBOX(model_cbox, -1, self._on_select_model) 
    539         sizer_constraint.Add((5, -1)) 
     541        wx.EVT_COMBOBOX(model_cbox, wx.ID_ANY, self._on_select_model) 
     542        sizer_constraint.Add((5, wx.ID_ANY)) 
    540543        sizer_constraint.Add(model_cbox, flag=wx.RIGHT | wx.EXPAND, border=10) 
    541544        sizer_constraint.Add(param_cbox, flag=wx.RIGHT | wx.EXPAND, border=5) 
     
    672675        """ 
    673676        self.sizer3.Clear(True) 
    674         box_description = wx.StaticBox(self, -1, "Fit ") 
     677        box_description = wx.StaticBox(self, wx.ID_ANY, "Fit ") 
    675678        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    676679        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    677680 
    678         self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=wx.DefaultSize) 
     681        self.btFit = wx.Button(self, self.ID_FIT, 'Fit', size=wx.DefaultSize) 
    679682        self.btFit.Bind(wx.EVT_BUTTON, self.onFit, id=self.btFit.GetId()) 
    680683        self.btFit.SetToolTipString("Perform fit.") 
     
    684687            text = " This page requires at least one FitPage with a data\n" 
    685688            text = " and a model for fitting." 
    686         text_hint = wx.StaticText(self, -1, text) 
     689        text_hint = wx.StaticText(self, wx.ID_ANY, text) 
    687690 
    688691        sizer_button.Add(text_hint, wx.RIGHT | wx.EXPAND, 10) 
     
    705708                self.sizer2.Show(False) 
    706709            return 
    707         box_description = wx.StaticBox(self, -1, "Fit Constraints") 
     710        box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Constraints") 
    708711        boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 
    709712        sizer_title = wx.BoxSizer(wx.HORIZONTAL) 
     
    712715        sizer_button = wx.BoxSizer(wx.HORIZONTAL) 
    713716 
    714         self.hide_constraint = wx.RadioButton(self, -1, 'No', (10, 10), 
     717        self.hide_constraint = wx.RadioButton(self, wx.ID_ANY, 'No', (10, 10), 
    715718                                              style=wx.RB_GROUP) 
    716         self.show_constraint = wx.RadioButton(self, -1, 'Yes', (10, 30)) 
     719        self.show_constraint = wx.RadioButton(self, wx.ID_ANY, 'Yes', (10, 30)) 
    717720        self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 
    718721                  id=self.hide_constraint.GetId()) 
     
    725728        self.show_constraint.SetValue(False) 
    726729 
    727         sizer_title.Add(wx.StaticText(self, -1, " Model")) 
     730        sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Model")) 
    728731        sizer_title.Add((10, 10)) 
    729         sizer_title.Add(wx.StaticText(self, -1, " Parameter")) 
     732        sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Parameter")) 
    730733        sizer_title.Add((10, 10)) 
    731         sizer_title.Add(wx.StaticText(self, -1, " Add Constraint?")) 
     734        sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Add Constraint?")) 
    732735        sizer_title.Add((10, 10)) 
    733736        sizer_title.Add(self.show_constraint) 
     
    735738        sizer_title.Add((10, 10)) 
    736739 
    737         self.btAdd = wx.Button(self, wx.NewId(), 'Add') 
     740        self.btAdd = wx.Button(self, self.ID_ADD, 'Add') 
    738741        self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint, 
    739742                        id=self.btAdd.GetId()) 
     
    741744        self.btAdd.Hide() 
    742745 
    743         text_hint = wx.StaticText(self, -1, 
     746        text_hint = wx.StaticText(self, wx.ID_ANY, 
    744747                                  "Example: [M0][paramter] = M1.parameter") 
    745748        sizer_button.Add(text_hint, 0 , wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 
     
    821824        sizer.Clear(True) 
    822825 
    823         new_name = wx.StaticText(self, -1, '  Model Title ', 
     826        new_name = wx.StaticText(self, wx.ID_ANY, '  Model Title ', 
    824827                                 style=wx.ALIGN_CENTER) 
    825828        new_name.SetBackgroundColour('orange') 
     
    828831                            wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 
    829832        ix += 2 
    830         model_type = wx.StaticText(self, -1, '  Model ') 
     833        model_type = wx.StaticText(self, wx.ID_ANY, '  Model ') 
    831834        model_type.SetBackgroundColour('grey') 
    832835        model_type.SetForegroundColour(wx.WHITE) 
     
    834837                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    835838        ix += 1 
    836         data_used = wx.StaticText(self, -1, '  Data ') 
     839        data_used = wx.StaticText(self, wx.ID_ANY, '  Data ') 
    837840        data_used.SetBackgroundColour('grey') 
    838841        data_used.SetForegroundColour(wx.WHITE) 
     
    840843                            wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    841844        ix += 1 
    842         tab_used = wx.StaticText(self, -1, '  FitPage ') 
     845        tab_used = wx.StaticText(self, wx.ID_ANY, '  FitPage ') 
    843846        tab_used.SetBackgroundColour('grey') 
    844847        tab_used.SetForegroundColour(wx.WHITE) 
     
    879882            if model is not None: 
    880883                name = str(model.name) 
    881             cb = wx.CheckBox(self, -1, name) 
     884            cb = wx.CheckBox(self, wx.ID_ANY, name) 
    882885            cb.SetValue(False) 
    883886            cb.Enable(model is not None and data.is_data) 
     
    887890            ix += 2 
    888891            type = model.__class__.__name__ 
    889             model_type = wx.StaticText(self, -1, str(type)) 
     892            model_type = wx.StaticText(self, wx.ID_ANY, str(type)) 
    890893            sizer.Add(model_type, (iy, ix), (1, 1), 
    891894                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
    892895            if self.batch_on: 
    893                 data_used = wx.ComboBox(self, -1, style=wx.CB_READONLY) 
     896                data_used = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 
    894897                data_used.AppendItems(data_list) 
    895898                data_used.SetSelection(0) 
    896899            else: 
    897                 data_used = wx.StaticText(self, -1, data_list[0]) 
     900                data_used = wx.StaticText(self, wx.ID_ANY, data_list[0]) 
    898901 
    899902            ix += 1 
     
    902905            ix += 1 
    903906            caption = value.get_fit_tab_caption() 
    904             tab_caption_used = wx.StaticText(self, -1, str(caption)) 
     907            tab_caption_used = wx.StaticText(self, wx.ID_ANY, str(caption)) 
    905908            sizer.Add(tab_caption_used, (iy, ix), (1, 1), 
    906909                      wx.EXPAND | wx.ADJUST_MINSIZE, 0) 
Note: See TracChangeset for help on using the changeset viewer.