Changeset 1590


Ignore:
Timestamp:
Dec 1, 2014 4:08:22 PM (9 years ago)
Author:
toby
Message:

update grid cell editor for wx2.9+ change (see http://wxpython.org/migrationguide.php); create a GridCellAttr? for each Set...Attr()call

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIgrid.py

    r1583 r1590  
    22882288        self._tc.SetSelection(0, self._tc.GetLastPosition())
    22892289
    2290     def EndEdit(self, row, col, grid):
     2290    def EndEdit(self, row, col, grid, oldVal=None):
    22912291        changed = False
    22922292
     2293        self.nextval = self.startValue
    22932294        val = self._tc.GetValue().lower()
    2294        
    22952295        if val != self.startValue:
    22962296            changed = True
     
    23112311                    val = 'cosd('+val.strip('c')+')'
    23122312            try:
    2313                 val = float(eval(val))
    2314             except (SyntaxError,NameError):
     2313                self.nextval = val = float(eval(val))
     2314            except (SyntaxError,NameError,ZeroDivisionError):
    23152315                val = self.startValue
    2316             grid.GetTable().SetValue(row, col, val) # update the table
     2316                return None
     2317           
     2318            if oldVal is None: # this arg appears in 2.9+; before, we should go ahead & change the table
     2319                grid.GetTable().SetValue(row, col, val) # update the table
     2320            # otherwise self.ApplyEdit gets called
    23172321
    23182322        self.startValue = ''
    23192323        self._tc.SetValue('')
    23202324        return changed
     2325   
     2326    def ApplyEdit(self, row, col, grid):
     2327        """ Called only in wx >= 2.9
     2328        Save the value of the control into the grid if EndEdit() returns as True
     2329        """
     2330        grid.GetTable().SetValue(row, col, self.nextval) # update the table
    23212331
    23222332    def Reset(self):
  • trunk/GSASIIphsGUI.py

    r1589 r1590  
    12921292            attr.SetEditor(G2gd.GridFractionEditor(Atoms))
    12931293            for c in range(colX,colX+3):
     1294                attr = wx.grid.GridCellAttr()
     1295                attr.IncRef()               #fix from Jim Hester
     1296                attr.SetEditor(G2gd.GridFractionEditor(Atoms))
    12941297                Atoms.SetColAttr(c, attr)
    12951298            for i in range(colU11-1,colU11+6):
Note: See TracChangeset for help on using the changeset viewer.