I know, I know, this topic has been discussed before-- seemingly beaten to death actually. I’ve found many threads on the issue, but I can’t wrap my head around the idea, nor can I get any examples to work.
I created a file (attached) based on wxPython in Action, pages 131-132, and the example in the wxDemos MegaGrid example, plus made a couple small adjustments to reflect how I have things set up.
I am trying to delete a single row and have the table and grid update, and I am getting an error that I just can’t figure out. I’m not sure I understand why GetTypeName() and GetValue() are being called, let alone why they are throwing an error.
Does anybody have a simple, working example of deleting a row with PyGridTableBase?
I appreciate the help, and sorry for beating a dead horse,
I know, I know, this topic has been discussed before-- seemingly beaten
to death actually. I've found many threads on the issue, but I can't
wrap my head around the idea, nor can I get any examples to work.
I created a file (attached) based on wxPython in Action, pages 131-132,
and the example in the wxDemos MegaGrid example, plus made a couple
small adjustments to reflect how I have things set up.
I am trying to delete a single row and have the table and grid update,
and I am getting an error that I just can't figure out. I'm not sure I
understand why GetTypeName() and GetValue() are being called, let alone
why they are throwing an error.
They are being called because the grid is redrawing itself, so it needs to tell the cell renderers to draw their cells, and they need to get the value from the table so they know what to draw.
The problem is that you are deleting values from your data, but not telling the grid that the number of rows is less than what it was before. That is what the code in ResetView is trying to do, but it looks like you will need to adapt it to your code a little bit more.
Also, your GetTypeName is returning type(self.data[row][col + 1]) but that is going to result in a string like "<type 'str'>" but the grid is looking for type names like "string".
Thanks Robin, I’ll take a look and try to adapt that to my code. Still playing around with it.
Take care,
Jake
···
On Tuesday, July 9, 2013 5:36:22 PM UTC-4, Robin Dunn wrote:
Jake Larrimore wrote:
I know, I know, this topic has been discussed before-- seemingly beaten
to death actually. I’ve found many threads on the issue, but I can’t
wrap my head around the idea, nor can I get any examples to work.
I created a file (attached) based on wxPython in Action, pages 131-132,
and the example in the wxDemos MegaGrid example, plus made a couple
small adjustments to reflect how I have things set up.
I am trying to delete a single row and have the table and grid update,
and I am getting an error that I just can’t figure out. I’m not sure I
understand why GetTypeName() and GetValue() are being called, let alone
why they are throwing an error.
They are being called because the grid is redrawing itself, so it needs
to tell the cell renderers to draw their cells, and they need to get the
value from the table so they know what to draw.
The problem is that you are deleting values from your data, but not
telling the grid that the number of rows is less than what it was
before. That is what the code in ResetView is trying to do, but it
looks like you will need to adapt it to your code a little bit more.
Also, your GetTypeName is returning type(self.data[row][col + 1]) but
that is going to result in a string like “<type ‘str’>” but the grid is
looking for type names like “string”.