Changeset 4913 for trunk/GSASIIctrlGUI.py
- Timestamp:
- May 22, 2021 7:13:58 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/GSASIIctrlGUI.py
r4912 r4913 4501 4501 self.SetCellBackgroundColour(r,c,color) 4502 4502 self.SetReadOnly(r,c,isReadOnly=readonly) 4503 4503 4504 def SetTable(self, table, *args, **kwargs): 4505 '''Overrides the standard SetTable method with one that uses 4506 GridFractionEditor for all numeric columns (unless useFracEdit 4507 is false) 4508 ''' 4509 setFracEdit = kwargs.get('useFracEdit',True) 4510 if 'useFracEdit' in kwargs: del kwargs['useFracEdit'] 4511 wg.Grid.SetTable(self, table, *args, **kwargs) 4512 if setFracEdit: 4513 for i,t in enumerate(table.dataTypes): 4514 if not t.startswith(wg.GRID_VALUE_FLOAT): continue 4515 attr = wx.grid.GridCellAttr() 4516 attr.IncRef() 4517 attr.SetEditor(GridFractionEditor(self)) 4518 self.SetColAttr(i, attr) 4519 4504 4520 def GetSelection(self): 4505 4521 #this is to satisfy structure drawing stuff in G2plt when focus changes … … 4771 4787 class GridFractionEditor(wg.PyGridCellEditor): 4772 4788 '''A grid cell editor class that allows entry of values as fractions as well 4773 as sine and cosine values [as s() and c()] 4789 as sine and cosine values [as s() and c(), sin() or sind(), etc]. Any valid 4790 Python expression will be evaluated. 4791 4792 The current value can be incremented, multiplied or divided by prefixing 4793 an expression by +, * or / respectively. 4774 4794 ''' 4775 4795 def __init__(self,grid): … … 4812 4832 changed = True 4813 4833 neg = False 4834 mult = False 4835 divide = False 4836 add = False 4837 if val.startswith('*'): 4838 mult = True 4839 val = val[1:] 4840 elif val.startswith('/'): 4841 divide = True 4842 val = val[1:] 4843 elif val.startswith('+'): 4844 add = True 4845 val = val[1:] 4814 4846 if val.startswith('-'): 4815 4847 neg = True … … 4824 4856 val = G2py3.FormulaEval(val) 4825 4857 if val is not None: 4826 self.nextval = val 4858 if mult: 4859 self.nextval *= val 4860 elif divide: 4861 if val != 0: self.nextval /= val 4862 elif add: 4863 self.nextval += val 4864 else: 4865 self.nextval = val 4827 4866 else: 4828 4867 return None
Note: See TracChangeset
for help on using the changeset viewer.