Ignore:
Timestamp:
Feb 20, 2021 9:43:32 AM (2 years ago)
Author:
toby
Message:

Warn if param limits on constrained vars

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIctrlGUI.py

    r4819 r4822  
    41534153        self.SetItemCount(0)
    41544154
    4155         self.attr1 = wx.ListItemAttr()
     4155        try:
     4156            self.attr1 = wx.ItemAttr()
     4157        except:
     4158            self.attr1 = wx.ListItemAttr() # deprecated in wx4.1
    41564159        self.attr1.SetBackgroundColour((255,255,150))
    41574160
     
    43214324        # draw min value widgets
    43224325        mainSizer.Add((-1,10),0)
    4323         n,val = G2obj.prmLookup(name,self.parmWin.Controls['parmMinDict']) # is this a wild-card?
    4324         if val is None:
    4325             addMbtn = wx.Button(dlg, wx.ID_ANY,'Add Lower limit')
    4326             addMbtn.Bind(wx.EVT_BUTTON, AddM)
    4327             mainSizer.Add(addMbtn,0)
    4328         else:
    4329             subSizer = wx.BoxSizer(wx.HORIZONTAL)
    4330             subSizer.Add(wx.StaticText(dlg,wx.ID_ANY,'Minimum limit'),0,wx.CENTER)
    4331             subSizer.Add(ValidatedTxtCtrl(dlg,self.parmWin.Controls['parmMinDict'],n,nDig=(10,2,'g')),0,WACV)
    4332             delMbtn = wx.Button(dlg, wx.ID_ANY,'Delete',style=wx.BU_EXACTFIT)
    4333             subSizer.Add((5,-1),0,WACV)
    4334             subSizer.Add(delMbtn,0,WACV)
    4335             delMbtn.Bind(wx.EVT_BUTTON, delM)
    4336             if name.split(':')[1]:             # is this using a histogram?
     4326        if name not in self.parmWin.varyList and name in self.parmWin.fullVaryList:
     4327            mainSizer.Add(wx.StaticText(dlg,wx.ID_ANY,'Limits not allowed on constrained variables'),0)
     4328            for key in 'parmMinDict','parmMaxDict':
     4329                d = self.parmWin.Controls[key]
     4330                n,v = G2obj.prmLookup(name,d)
     4331                if v is not None and str(n) == name:
     4332                    try:  # strange hard to reproduce problem with this not working
     4333                        del d[n]
     4334                    except:
     4335                        if GSASIIpath.GetConfigValue('debug'):
     4336                            print('debug: failed to delete ',name,'in',key)
     4337
     4338        else:
     4339            n,val = G2obj.prmLookup(name,self.parmWin.Controls['parmMinDict']) # is this a wild-card?
     4340            if val is None:
     4341                addMbtn = wx.Button(dlg, wx.ID_ANY,'Add Lower limit')
     4342                addMbtn.Bind(wx.EVT_BUTTON, AddM)
     4343                mainSizer.Add(addMbtn,0)
     4344            else:
     4345                subSizer = wx.BoxSizer(wx.HORIZONTAL)
     4346                subSizer.Add(wx.StaticText(dlg,wx.ID_ANY,'Minimum limit'),0,wx.CENTER)
     4347                subSizer.Add(ValidatedTxtCtrl(dlg,self.parmWin.Controls['parmMinDict'],n,nDig=(10,2,'g')),0,WACV)
     4348                delMbtn = wx.Button(dlg, wx.ID_ANY,'Delete',style=wx.BU_EXACTFIT)
    43374349                subSizer.Add((5,-1),0,WACV)
    4338                 wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all histograms ')
    4339                 wild.SetValue(str(n).split(':')[1] == '*')
    4340                 wild.Bind(wx.EVT_CHECKBOX,SetWild)
    4341                 wild.hist = True
    4342                 subSizer.Add(wild,0,WACV)
    4343             elif len(name.split(':')) > 3:
     4350                subSizer.Add(delMbtn,0,WACV)
     4351                delMbtn.Bind(wx.EVT_BUTTON, delM)
     4352                if name.split(':')[1]:             # is this using a histogram?
     4353                    subSizer.Add((5,-1),0,WACV)
     4354                    wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all histograms ')
     4355                    wild.SetValue(str(n).split(':')[1] == '*')
     4356                    wild.Bind(wx.EVT_CHECKBOX,SetWild)
     4357                    wild.hist = True
     4358                    subSizer.Add(wild,0,WACV)
     4359                elif len(name.split(':')) > 3:
     4360                    subSizer.Add((5,-1),0,WACV)
     4361                    wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all atoms ')
     4362                    wild.SetValue(str(n).split(':')[3] == '*')
     4363                    wild.Bind(wx.EVT_CHECKBOX,SetWild)
     4364                    subSizer.Add(wild,0,WACV)
     4365                mainSizer.Add(subSizer,0)
     4366            # draw max value widgets
     4367            mainSizer.Add((-1,10),0)
     4368            n,val = G2obj.prmLookup(name,self.parmWin.Controls['parmMaxDict']) # is this a wild-card?
     4369            if val is None:
     4370                addMbtn = wx.Button(dlg, wx.ID_ANY,'Add Upper limit')
     4371                addMbtn.Bind(wx.EVT_BUTTON, AddM)
     4372                addMbtn.max = True
     4373                mainSizer.Add(addMbtn,0)
     4374            else:
     4375                subSizer = wx.BoxSizer(wx.HORIZONTAL)
     4376                subSizer.Add(wx.StaticText(dlg,wx.ID_ANY,'Maximum limit'),0,wx.CENTER)
     4377                subSizer.Add(ValidatedTxtCtrl(dlg,self.parmWin.Controls['parmMaxDict'],n,nDig=(10,2,'g')),0,WACV)
     4378                delMbtn = wx.Button(dlg, wx.ID_ANY,'Delete',style=wx.BU_EXACTFIT)
    43444379                subSizer.Add((5,-1),0,WACV)
    4345                 wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all atoms ')
    4346                 wild.SetValue(str(n).split(':')[3] == '*')
    4347                 wild.Bind(wx.EVT_CHECKBOX,SetWild)
    4348                 subSizer.Add(wild,0,WACV)
    4349             mainSizer.Add(subSizer,0)
    4350         # draw max value widgets
    4351         mainSizer.Add((-1,10),0)
    4352         n,val = G2obj.prmLookup(name,self.parmWin.Controls['parmMaxDict']) # is this a wild-card?
    4353         if val is None:
    4354             addMbtn = wx.Button(dlg, wx.ID_ANY,'Add Upper limit')
    4355             addMbtn.Bind(wx.EVT_BUTTON, AddM)
    4356             addMbtn.max = True
    4357             mainSizer.Add(addMbtn,0)
    4358         else:
    4359             subSizer = wx.BoxSizer(wx.HORIZONTAL)
    4360             subSizer.Add(wx.StaticText(dlg,wx.ID_ANY,'Maximum limit'),0,wx.CENTER)
    4361             subSizer.Add(ValidatedTxtCtrl(dlg,self.parmWin.Controls['parmMaxDict'],n,nDig=(10,2,'g')),0,WACV)
    4362             delMbtn = wx.Button(dlg, wx.ID_ANY,'Delete',style=wx.BU_EXACTFIT)
    4363             subSizer.Add((5,-1),0,WACV)
    4364             subSizer.Add(delMbtn,0,WACV)
    4365             delMbtn.Bind(wx.EVT_BUTTON, delM)
    4366             delMbtn.max = True
    4367             if name.split(':')[1]:             # is this using a histogram?
    4368                 subSizer.Add((5,-1),0,WACV)
    4369                 wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all histograms ')
    4370                 wild.SetValue(str(n).split(':')[1] == '*')
    4371                 wild.Bind(wx.EVT_CHECKBOX,SetWild)
    4372                 wild.max = True
    4373                 wild.hist = True
    4374                 subSizer.Add(wild,0,WACV)
    4375             elif len(name.split(':')) > 3:
    4376                 subSizer.Add((5,-1),0,WACV)
    4377                 wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all atoms ')
    4378                 wild.SetValue(str(n).split(':')[3] == '*')
    4379                 wild.Bind(wx.EVT_CHECKBOX,SetWild)
    4380                 wild.max = True
    4381                 subSizer.Add(wild,0,WACV)
    4382             mainSizer.Add(subSizer,0)
     4380                subSizer.Add(delMbtn,0,WACV)
     4381                delMbtn.Bind(wx.EVT_BUTTON, delM)
     4382                delMbtn.max = True
     4383                if name.split(':')[1]:             # is this using a histogram?
     4384                    subSizer.Add((5,-1),0,WACV)
     4385                    wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all histograms ')
     4386                    wild.SetValue(str(n).split(':')[1] == '*')
     4387                    wild.Bind(wx.EVT_CHECKBOX,SetWild)
     4388                    wild.max = True
     4389                    wild.hist = True
     4390                    subSizer.Add(wild,0,WACV)
     4391                elif len(name.split(':')) > 3:
     4392                    subSizer.Add((5,-1),0,WACV)
     4393                    wild = wx.CheckBox(dlg,wx.ID_ANY,label='Match all atoms ')
     4394                    wild.SetValue(str(n).split(':')[3] == '*')
     4395                    wild.Bind(wx.EVT_CHECKBOX,SetWild)
     4396                    wild.max = True
     4397                    subSizer.Add(wild,0,WACV)
     4398                mainSizer.Add(subSizer,0)
    43834399           
    43844400        btnsizer = wx.StdDialogButtonSizer()
Note: See TracChangeset for help on using the changeset viewer.