Changeset 2639 for trunk/GSASIIctrls.py
- Timestamp:
- Jan 17, 2017 4:46:55 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrls.py
r2637 r2639 2946 2946 2947 2947 self.nextval = self.startValue 2948 val = self._tc.GetValue().lower() 2948 val = self._tc.GetValue().lower().strip() 2949 2949 if val != self.startValue: 2950 2950 changed = True 2951 2951 neg = False 2952 if '-' in val:2952 if val.startswith('-'): 2953 2953 neg = True 2954 if '/' in val and '.' not in val: 2955 val += '.' 2956 elif 's' in val and not 'sind(' in val: 2957 if neg: 2958 val = '-sind('+val.strip('-s')+')' 2959 else: 2960 val = 'sind('+val.strip('s')+')' 2961 elif 'c' in val and not 'cosd(' in val: 2962 if neg: 2963 val = '-cosd('+val.strip('-c')+')' 2964 else: 2965 val = 'cosd('+val.strip('c')+')' 2966 try: 2967 self.nextval = val = float(eval(val)) 2968 except (SyntaxError,NameError,ZeroDivisionError): 2969 val = self.startValue 2954 val = val[1:] 2955 # allow old GSAS s20 and c20 etc for sind(20) and cosd(20) 2956 if val.startswith('s') and '(' not in val: 2957 val = 'sind('+val.strip('s')+')' 2958 elif val.startswith('c') and '(' not in val: 2959 val = 'cosd('+val.strip('c')+')' 2960 if neg: 2961 val = '-' + val 2962 val = G2py3.FormulaEval(val) 2963 if val: 2964 self.nextval = val 2965 else: 2970 2966 return None 2971 2972 2967 if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table 2973 2968 grid.GetTable().SetValue(row, col, val) # update the table … … 2998 2993 def OnChar(self, evt): 2999 2994 key = evt.GetKeyCode() 3000 if key == 15: 3001 return 3002 if key > 255: 2995 if key < 32 or key >= 127: 3003 2996 evt.Skip() 3004 return 3005 char = chr(key) 3006 if char in '.+-/0123456789cosind()': 3007 self._tc.WriteText(char) 3008 else: 2997 elif chr(key).lower() in '.+-*/0123456789cosind()': 3009 2998 evt.Skip() 2999 else: 3000 evt.StopPropagation() 3010 3001 3011 3002 ################################################################################ … … 4250 4241 frm.Show(True) 4251 4242 4243 #====================================================================== 4244 # test Grid with GridFractionEditor 4245 #====================================================================== 4246 tbl = [[1.,2.,3.],[1.1,2.1,3.1]] 4247 colTypes = 3*[wg.GRID_VALUE_FLOAT+':10,5',] 4248 Gtbl = Table(tbl,types=colTypes,rowLabels=['a','b'],colLabels=['1','2','3']) 4249 Grid = GSGrid(frm) 4250 Grid.SetTable(Gtbl,True) 4251 for i in (0,1,2): 4252 attr = wx.grid.GridCellAttr() 4253 attr.IncRef() 4254 attr.SetEditor(GridFractionEditor(Grid)) 4255 Grid.SetColAttr(i, attr) 4256 frm.SetSize((400,200)) 4257 app.MainLoop() 4258 sys.exit() 4259 #====================================================================== 4260 # test Tutorial access 4261 #====================================================================== 4252 4262 dlg = OpenTutorial(frm) 4253 4263 if dlg.ShowModal() == wx.ID_OK:
Note: See TracChangeset
for help on using the changeset viewer.