92 |
wxPyGridTableBase.__init__(self) |
wxPyGridTableBase.__init__(self) |
93 |
self.num_cols = 1 |
self.num_cols = 1 |
94 |
self.num_rows = 0 |
self.num_rows = 0 |
|
self.columns = [] |
|
95 |
self.table = None |
self.table = None |
96 |
self.record_index = record |
self.record_index = record |
97 |
self.record = None |
self.record = None |
169 |
def SetValue(self, row, col, value): |
def SetValue(self, row, col, value): |
170 |
if row < self.num_rows: |
if row < self.num_rows: |
171 |
name = self.rows[row][0] |
name = self.rows[row][0] |
172 |
print "Set value of field %s to %s" % (name, value) |
self.record[name] = value |
173 |
|
self.table.write_record(self.record_index, {name: value}) |
174 |
|
|
175 |
# |
# |
176 |
# Some optional methods |
# Some optional methods |
189 |
# default, doesn't necessarily have to be the same type used |
# default, doesn't necessarily have to be the same type used |
190 |
# nativly by the editor/renderer if they know how to convert. |
# nativly by the editor/renderer if they know how to convert. |
191 |
def GetTypeName(self, row, col): |
def GetTypeName(self, row, col): |
192 |
if row < self.num_rows: |
# for some reason row and col may be negative sometimes, but |
193 |
|
# it's probably a wx bug (filed as #593189 on sourceforge) |
194 |
|
if 0 <= row < self.num_rows: |
195 |
return self.rows[row][1] |
return self.rows[row][1] |
196 |
return wxGRID_VALUE_STRING |
return wxGRID_VALUE_STRING |
197 |
|
|
205 |
def CanSetValueAs(self, row, col, typeName): |
def CanSetValueAs(self, row, col, typeName): |
206 |
return self.CanGetValueAs(row, col, typeName) |
return self.CanGetValueAs(row, col, typeName) |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
class RecordGridCtrl(wxGrid): |
class RecordGridCtrl(wxGrid): |
211 |
|
|
226 |
self.AutoSizeColumn(0, true) |
self.AutoSizeColumn(0, true) |
227 |
|
|
228 |
#self.SetSelectionMode(wxGrid.wxGridSelectRows) |
#self.SetSelectionMode(wxGrid.wxGridSelectRows) |
229 |
|
|
230 |
#EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
#EVT_GRID_RANGE_SELECT(self, self.OnRangeSelect) |
231 |
#EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
#EVT_GRID_SELECT_CELL(self, self.OnSelectCell) |
232 |
|
|