Changeset 1324 for trunk/GSASIIexprGUI.py
- Timestamp:
- May 5, 2014 3:54:51 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIexprGUI.py
r1322 r1324 30 30 import GSASIIpy3 as G2py3 31 31 import GSASIIobj as G2obj 32 33 def IndexParmDict(parmDict,wildcard): 34 '''Separate the parameters in parmDict into list of keys by parameter 35 type 36 :param dict parmDict: a dict with GSAS-II parameters 37 :param bool wildcard: True if wildcard versions of parameters should 38 be generated and added to the lists 39 :returns: a dict of lists where key 1 is a list of phase parameters, 40 2 is histogram/phase parms, 3 is histogram parms and 4 are global parameters 41 ''' 42 prex = re.compile('[0-9]+::.*') 43 hrex = re.compile(':[0-9]+:.*') 44 parmLists = {} 45 for i in (1,2,3,4): 46 parmLists[i] = [] 47 for i in sorted(parmDict.keys()): 48 if i.startswith("::") or i.find(':') == -1: # globals 49 parmLists[4].append(i) 50 elif prex.match(i): 51 parmLists[1].append(i) 52 elif hrex.match(i): 53 parmLists[3].append(i) 54 else: 55 parmLists[2].append(i) 56 if wildcard: 57 for i in (1,2,3,4): 58 parmLists[i] += G2obj.GenWildCard(parmLists[i]) # generate wildcard versions 59 for i in (1,2,3,4): 60 parmLists[i].sort() 61 return parmLists 32 62 33 63 #========================================================================== … … 119 149 except: 120 150 pass 121 prex = re.compile('[0-9]+::.*') 122 hrex = re.compile(':[0-9]+:.*') 123 self.parmLists = {} 124 for i in (1,2,3,4): 125 self.parmLists[i] = [] 126 for i in sorted(self.parmDict.keys()): 127 if i.startswith("::") or i.find(':') == -1: # globals 128 self.parmLists[4].append(i) 129 elif prex.match(i): 130 self.parmLists[1].append(i) 131 elif hrex.match(i): 132 self.parmLists[3].append(i) 133 else: 134 self.parmLists[2].append(i) 135 if self.fit: 136 for i in (1,2,3,4): 137 wildList = G2obj.GenWildCard(self.parmLists[i]) 138 self.parmLists[i] += wildList 139 self.parmLists[i].sort() 140 151 # separate the variables by type 152 self.parmLists = IndexParmDict(self.parmDict,self.fit) 141 153 self.timer = wx.Timer() 142 154 self.timer.Bind(wx.EVT_TIMER,self.OnValidate) … … 333 345 0,wx.ALIGN_CENTER) 334 346 lbls = ('varib. type\nselection','variable\nname','value') 335 self.choices = ['Free','Phase','Hist./Phase','Hist.','Global']347 choices = ['Free','Phase','Hist./Phase','Hist.','Global'] 336 348 if self.fit: 337 349 lbls += ('refine\nflag',) 338 350 else: 339 351 lbls += ('',) 340 self.choices[0] = '' 341 for i in (1,2,3,4): # remove empty menus from choice list 342 if not len(self.parmLists[i]): self.choices[i] = '' 343 352 choices[0] = '' 353 for i in range(1,len(choices)): # remove empty menus from choice list 354 if not len(self.parmLists[i]): choices[i] = '' 355 356 self.AllowedChoices = [i for i in range(len(choices)) if choices[i]] 344 357 for lbl in lbls: 345 358 w = wx.StaticText(self.varbox,wx.ID_ANY,lbl,style=wx.CENTER) … … 352 365 GridSiz.Add(wx.StaticText(self.varbox,wx.ID_ANY,v),0,wx.ALIGN_CENTER,0) 353 366 # assignment type 354 self.ch = wx.Choice(367 ch = wx.Choice( 355 368 self.varbox, wx.ID_ANY, 356 choices = self.choices) 357 GridSiz.Add(self.ch,0,wx.ALIGN_LEFT,0) 358 self.ch.SetSelection(self.varSelect.get(v,wx.NOT_FOUND)) 359 self.ch.label = v 360 self.ch.Bind(wx.EVT_CHOICE,self.OnChoice) 369 choices = [choices[i] for i in self.AllowedChoices] 370 ) 371 GridSiz.Add(ch,0,wx.ALIGN_LEFT,0) 372 if v in self.varSelect and self.varSelect.get(v) in self.AllowedChoices: 373 i = self.AllowedChoices.index(self.varSelect[v]) 374 ch.SetSelection(i) 375 else: 376 ch.SetSelection(wx.NOT_FOUND) 377 ch.label = v 378 ch.Bind(wx.EVT_CHOICE,self.OnChoice) 361 379 362 380 # var name/var assignment … … 425 443 ''' 426 444 v = event.GetEventObject().label 427 sel = event.GetEventObject().GetSelection() 428 if self.choices[sel] == '': 429 if v in self.varSelect: del self.varSelect[v] 430 sel = event.GetEventObject().GetSelection() 431 self.OnValidate(None) 432 return 445 sel = self.AllowedChoices[event.GetEventObject().GetSelection()] 433 446 self.varSelect[v] = sel 434 447 if sel == 0: … … 439 452 if not var: 440 453 del self.varSelect[v] 441 sel = event.GetEventObject().GetSelection()442 454 self.OnValidate(None) 443 455 return
Note: See TracChangeset
for help on using the changeset viewer.