# HG changeset patch # User Laurent Bessard # Date 1372975881 -7200 # Node ID 8d4de18c9f295730162d299e8bc864e46e846092 # Parent 6b38acbe1fd0c452491ae129dcac2d4d9db8fb36 Fixed DurationCellEditor to make it reusable diff -r 6b38acbe1fd0 -r 8d4de18c9f29 controls/DurationCellEditor.py --- a/controls/DurationCellEditor.py Fri Jul 05 00:10:29 2013 +0200 +++ b/controls/DurationCellEditor.py Fri Jul 05 00:11:21 2013 +0200 @@ -98,10 +98,11 @@ ''' Grid cell editor that uses DurationCellControl to display an edit button. ''' - def __init__(self, table): + def __init__(self, table, colname): wx.grid.PyGridCellEditor.__init__(self) self.Table = table + self.Colname = colname def __del__(self): self.CellControl = None @@ -114,15 +115,15 @@ def BeginEdit(self, row, col, grid): self.CellControl.Enable() - self.CellControl.SetValue(self.Table.GetValueByName(row, 'Interval')) + self.CellControl.SetValue(self.Table.GetValueByName(row, self.Colname)) self.CellControl.SetFocus() def EndEdit(self, row, col, grid): duration = self.CellControl.GetValue() - old_duration = self.Table.GetValueByName(row, 'Interval') + old_duration = self.Table.GetValueByName(row, self.Colname) changed = duration != old_duration if changed: - self.Table.SetValueByName(row, 'Interval', duration) + self.Table.SetValueByName(row, self.Colname, duration) self.CellControl.Disable() return changed diff -r 6b38acbe1fd0 -r 8d4de18c9f29 editors/ResourceEditor.py --- a/editors/ResourceEditor.py Fri Jul 05 00:10:29 2013 +0200 +++ b/editors/ResourceEditor.py Fri Jul 05 00:11:21 2013 +0200 @@ -140,7 +140,7 @@ editor = wx.grid.GridCellTextEditor() renderer = wx.grid.GridCellStringRenderer() elif colname == "Interval": - editor = DurationCellEditor(self) + editor = DurationCellEditor(self, colname) renderer = wx.grid.GridCellStringRenderer() if self.GetValueByName(row, "Triggering") != "Cyclic": grid.SetReadOnly(row, col, True)