Changeset 1202
- Timestamp:
- Jan 20, 2014 12:24:54 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/GSASIIgrid.py ¶
r1201 r1202 224 224 use of a single '?' or '.' character as valid input. 225 225 226 :param dict OnLeaveArgs: a dict with keyword args that are passed to 227 the :attr:`OnLeave` function. Defaults to ``{}`` 228 226 229 :param (other): other optional keyword parameters for the 227 230 wx.TextCtrl widget such as Size or Style may be specified. … … 230 233 def __init__(self,parent,loc,key,nDig=None,notBlank=True,min=None,max=None, 231 234 OKcontrol=None,OnLeave=None,typeHint=None, 232 CIFinput=False, **kw):235 CIFinput=False, OnLeaveArgs={}, **kw): 233 236 # save passed values needed outside __init__ 234 237 self.result = loc … … 237 240 self.OKcontrol=OKcontrol 238 241 self.OnLeave = OnLeave 242 self.OnLeaveArgs = OnLeaveArgs 239 243 self.CIFinput = CIFinput 240 244 self.type = str … … 295 299 # When the mouse is moved away or the widget loses focus 296 300 # display the last saved value, if an expression 297 # self.Bind(wx.EVT_LEAVE_WINDOW, self._onLoseFocus)301 self.Bind(wx.EVT_LEAVE_WINDOW, self._onLeaveWindow) 298 302 self.Bind(wx.EVT_TEXT_ENTER, self._onLoseFocus) 299 303 self.Bind(wx.EVT_KILL_FOCUS, self._onLoseFocus) … … 396 400 if self.OnLeave: self.OnLeave(invalid=self.invalid, 397 401 value=self.result[self.key], 398 tc=self) 399 402 tc=self, 403 **self.OnLeaveArgs) 404 405 def _onLeaveWindow(self,event): 406 if self.evaluated: self.EvaluateExpression() 407 400 408 def EvaluateExpression(self): 401 409 '''Show the computed value when an expression is entered to the TextCtrl -
TabularUnified trunk/GSASIIobj.py ¶
r1192 r1202 1251 1251 if key is None: 1252 1252 return "" 1253 elif key == "*": 1254 return "*" 1253 1255 else: 1254 1256 return dic.get(key,'?') … … 1266 1268 object. If a string, it must be of form "p:h:var" or "p:h:var:a", where 1267 1269 1268 * p is the phase number (which may be left blank );1269 * h is the histogram number (which may be left blank );1270 * p is the phase number (which may be left blank or may be '*' to indicate all phases); 1271 * h is the histogram number (which may be left blank or may be '*' to indicate all histograms); 1270 1272 * a is the atom number (which may be left blank in which case the third colon is omitted). 1273 The atom number can be specified as '*' if a phase number is specified (not as '*') 1271 1274 1272 1275 Alternately a single tuple of form (Phase,Histogram,VarName,AtomID) can be used, where 1273 Phase, Histogram, and AtomID are None or are ranId values and VarName is a string. 1276 Phase, Histogram, and AtomID are None or are ranId values (or one can be '*') 1277 and VarName is a string. Note that if Phase is '*' then the AtomID is an atom number. 1274 1278 1275 1279 If four positional arguments are supplied, they are: 1276 1280 1277 :param str/int phasenum: The number for the phase 1278 :param str/int histnum: The number for the histogram 1281 :param str/int phasenum: The number for the phase (or None or '*') 1282 :param str/int histnum: The number for the histogram (or None or '*') 1279 1283 :param str varname: a single value can be used to create a :class:`G2VarObj` 1280 :param str/int atomnum: The number for the atom 1284 :param str/int atomnum: The number for the atom (or None or '*') 1281 1285 1282 1286 ''' … … 1294 1298 elif len(args) == 1 and ':' in args[0]: 1295 1299 lst = args[0].split(':') 1296 self.phase = PhaseIdLookup.get(lst[0],[None,None])[1] 1297 self.histogram = HistIdLookup.get(lst[1],[None,None])[1] 1300 if lst[0] == '*': 1301 self.phase = '*' 1302 if len(lst) > 3: 1303 self.atom = lst[3] 1304 else: 1305 self.phase = PhaseIdLookup.get(lst[0],[None,None])[1] 1306 if len(lst) > 3: 1307 if lst[3] == '*': 1308 self.atom = '*' 1309 else: 1310 self.atom = AtomIdLookup[lst[0]].get(lst[3],[None,None])[1] 1311 1312 if lst[1] == '*': 1313 self.histogram = '*' 1314 else: 1315 self.histogram = HistIdLookup.get(lst[1],[None,None])[1] 1298 1316 self.name = lst[2] 1299 if len(lst) > 3:1300 self.atom = AtomIdLookup[lst[0]].get(lst[3],[None,None])[1]1301 1317 elif len(args) == 4: 1302 self.phase = PhaseIdLookup.get(str(args[0]),[None,None])[1] 1303 self.histogram = HistIdLookup.get(str(args[1]),[None,None])[1] 1318 if args[0] == '*': 1319 self.phase = '*' 1320 self.atom = args[3] 1321 else: 1322 self.phase = PhaseIdLookup.get(str(args[0]),[None,None])[1] 1323 if args[3] == '*': 1324 self.atom = '*' 1325 elif args[0] is not None: 1326 self.atom = AtomIdLookup[args[0]].get(str(args[3]),[None,None])[1] 1327 if args[1] == '*': 1328 self.histogram = '*' 1329 else: 1330 self.histogram = HistIdLookup.get(str(args[1]),[None,None])[1] 1304 1331 self.name = args[2] 1305 self.atom = AtomIdLookup[args[0]].get(str(args[3]),[None,None])[1]1306 1332 else: 1307 1333 raise Exception,"Incorrectly called GSAS-II parameter name" … … 1318 1344 :returns: the variable name as a str 1319 1345 ''' 1320 ph = _lookup(PhaseRanIdLookup,self.phase) 1321 hist = _lookup(HistRanIdLookup,self.histogram) 1322 s = (ph + ":" + hist + ":" + 1323 str(self.name)) 1324 if self.atom: 1325 if ph in AtomRanIdLookup: 1326 s += ":" + AtomRanIdLookup[ph].get(self.atom,'?') 1327 else: 1328 s += ":?" 1346 a = "" 1347 if self.phase == "*": 1348 ph = "*" 1349 if self.atom: 1350 a = ":" + str(self.atom) 1351 else: 1352 ph = _lookup(PhaseRanIdLookup,self.phase) 1353 if self.atom == '*': 1354 a = ':*' 1355 elif self.atom: 1356 if ph in AtomRanIdLookup: 1357 a = ":" + AtomRanIdLookup[ph].get(self.atom,'?') 1358 else: 1359 a = ":?" 1360 if self.histogram == "*": 1361 hist = "*" 1362 else: 1363 hist = _lookup(HistRanIdLookup,self.histogram) 1364 s = (ph + ":" + hist + ":" + str(self.name)) + a 1329 1365 return s 1330 1366 … … 1333 1369 ''' 1334 1370 s = "<" 1335 if self.phase is not None: 1371 if self.phase == '*': 1372 s += "Phases: all; " 1373 if self.atom is not None: 1374 s += "Atom #" + str(self.atom) + "; " 1375 elif self.phase is not None: 1336 1376 ph = _lookup(PhaseRanIdLookup,self.phase) 1337 1377 s += "Phase: rId=" + str(self.phase) + " (#"+ ph + "); " 1338 if self.histogram is not None: 1378 if self.atom == '*': 1379 s += "Atoms: all; " 1380 elif self.atom is not None: 1381 s += "Atom rId=" + str(self.atom) 1382 if ph in AtomRanIdLookup: 1383 s += " (#" + AtomRanIdLookup[ph].get(self.atom,'?') + "); " 1384 else: 1385 s += " (#? -- not found!); " 1386 if self.histogram == '*': 1387 s += "Histograms: all; " 1388 elif self.histogram is not None: 1339 1389 hist = _lookup(HistRanIdLookup,self.histogram) 1340 1390 s += "Histogram: rId=" + str(self.histogram) + " (#"+ hist + "); " 1341 if self.atom is not None:1342 s += "Atom rId=" + str(self.atom)1343 if ph in AtomRanIdLookup:1344 s += " (#" + AtomRanIdLookup[ph].get(self.atom,'?') + "); "1345 else:1346 s += " (#? -- not found!); "1347 1391 s += 'Variable name="' + str(self.name) + '">' 1348 return s+" ("+self.varname()+")"1392 return s+" ("+self.varname()+")" 1349 1393 1350 1394 def __eq__(self, other):
Note: See TracChangeset
for help on using the changeset viewer.