I would like to have choice values in my wxGridTableBase (code is similar to the one in the demo) which come from my database.
Some code snippets:
at construction time I do this for types:
self.dataTypes = [wxGRID_VALUE_NUMBER,
wxGRID_VALUE_CHOICE + ':dummy1, dummy2',
wxGRID_VALUE_CHOICE + ':dummy3, dummy4',
wxGRID_VALUE_STRING,
wxGRID_VALUE_CHOICE + ':dummy5, dummy6']
Then I created a method with this code to set the editors and renderers again:
def SetEdRen(self, row, col):
args = self.choiceVal[col] # some choice values, will change it later to read from the db
edClass = self.colEdRen[col][0]
editor = apply(edClass, args) # pass e.g. choice list self.GetView().SetCellEditor(row, col, editor)
renClass = self.colEdRen[col][1]
renderer = apply(renClass, args) # pass e.g. float stuff as 6.2
self.GetView().SetCellRenderer(row, col, renderer)
Now if I call it in wxGridTableBase.GetValue it crashes the application.
If I call it in wxGridTableBase.SetValue I still get the choices set at construction time, or if I don't set self.dataTypes then I get an empty choice list.
Any hints on where I am going wrong here will be much appreciated.
I would like to have choice values in my wxGridTableBase (code is similar to the one in the demo) which come from my database.
Some code snippets:
at construction time I do this for types:
self.dataTypes = [wxGRID_VALUE_NUMBER,
wxGRID_VALUE_CHOICE + ':dummy1, dummy2',
wxGRID_VALUE_CHOICE + ':dummy3, dummy4',
wxGRID_VALUE_STRING,
wxGRID_VALUE_CHOICE + ':dummy5, dummy6']
Then I created a method with this code to set the editors and renderers again:
def SetEdRen(self, row, col):
args = self.choiceVal[col] # some choice values, will change it later to read from the db
edClass = self.colEdRen[col][0]
editor = apply(edClass, args) # pass e.g. choice list self.GetView().SetCellEditor(row, col, editor) renClass = self.colEdRen[col][1]
renderer = apply(renClass, args) # pass e.g. float stuff as 6.2
self.GetView().SetCellRenderer(row, col, renderer)
Now if I call it in wxGridTableBase.GetValue it crashes the application.
If I call it in wxGridTableBase.SetValue I still get the choices set at construction time, or if I don't set self.dataTypes then I get an empty choice list.
Any hints on where I am going wrong here will be much appreciated.
Try catching the EVT_GRID_EDITOR_CREATED event and then getting the control with event.GetControl() and then manipulating the contents of the wxComboBOx directly.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I would like to have choice values in my wxGridTableBase (code is similar to the one in the demo) which come from my database.
Some code snippets:
at construction time I do this for types:
self.dataTypes = [wxGRID_VALUE_NUMBER,
wxGRID_VALUE_CHOICE + ':dummy1, dummy2',
wxGRID_VALUE_CHOICE + ':dummy3, dummy4',
wxGRID_VALUE_STRING,
wxGRID_VALUE_CHOICE + ':dummy5, dummy6']
Then I created a method with this code to set the editors and renderers again:
def SetEdRen(self, row, col):
args = self.choiceVal[col] # some choice values, will change it later to read from the db
edClass = self.colEdRen[col][0]
editor = apply(edClass, args) # pass e.g. choice list self.GetView().SetCellEditor(row, col, editor) renClass = self.colEdRen[col][1]
renderer = apply(renClass, args) # pass e.g. float stuff as 6.2
self.GetView().SetCellRenderer(row, col, renderer)
Now if I call it in wxGridTableBase.GetValue it crashes the application.
If I call it in wxGridTableBase.SetValue I still get the choices set at construction time, or if I don't set self.dataTypes then I get an empty choice list.
Any hints on where I am going wrong here will be much appreciated.
Try catching the EVT_GRID_EDITOR_CREATED event and then getting the control with event.GetControl() and then manipulating the contents of the wxComboBOx directly.
This works like a charm! It is just amazing how simple things like this are - at least when one knows how
Try catching the EVT_GRID_EDITOR_CREATED event and then getting the control with event.GetControl() and then manipulating the contents of the wxComboBOx directly.
This works like a charm! It is just amazing how simple things like this are - at least when one knows how
Knows what? I just guessed.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!