[wxPython] wxGrid is not clearing internal row/column structures, makes invalid calls to table

When you delete items from a wxGrid (using my recipe from the wiki), the internal data structures don't seem to be updated. Symptoms:

     The mouse cursor changes to "resize" over the places where the grid-lines previously were.
     Clicking on any cell causes a call to the table's GetAttr(row,call,extra) method. Since the internal data is likely gone, this causes an assert.
     Trying to resize a grid-line causes an assert.

BTW: www.wxPython.org is refusing my connection attempts this evening. Don't know why. Can't find the "submit a bug" link at wxwindows.org.

Here's the code I'm using for the resizes:
     ### API Calls
     def ResetView(self):
         """Trim/extend the control's rows and update all values"""
         self.getGrid().BeginBatch()
         for current, new, delmsg, addmsg in [
             (self.currentRows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
             (self.currentColumns, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
         ]:
             if new < current:
                 msg = wxGridTableMessage(
                     self,
                     delmsg,
                     new, # position
                     current-new,
                 )
                 self.getGrid().ProcessTableMessage(msg)
             elif new > current:
                 msg = wxGridTableMessage(
                     self,
                     addmsg,
                     new-current
                 )
                 self.getGrid().ProcessTableMessage(msg)
         self.UpdateValues()
         self.getGrid().EndBatch()
     def UpdateValues( self ):
         """Update all displayed values"""
         msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
         self.getGrid().ProcessTableMessage(msg)

Enjoy,
Mike

···

_______________________________________
   Mike C. Fletcher
   Why, yes, I am looking for a job...
   http://members.rogers.com/mcfletch/

FWIW there has been mention on lots of problems with the grid control in the past... I don't know how useful it is at present.

Ellers

···

7/23/02 1:47:31 PM, "Mike C. Fletcher" <mcfletch@rogers.com> wrote:

When you delete items from a wxGrid (using my recipe from the wiki), the
internal data structures don't seem to be updated. Symptoms:

    The mouse cursor changes to "resize" over the places where the
grid-lines previously were.
    Clicking on any cell causes a call to the table's
GetAttr(row,call,extra) method. Since the internal data is likely gone,
this causes an assert.
    Trying to resize a grid-line causes an assert.

Well, in my experience:

  The 2.3.3pre5 grid works as advertised, and is usable for fairly involved projects. I use it extensively throughout the wxprop project, and from version 2.3.3pre4 and on, it's been basically reliable for me. Bugs surface, such as this one, but as is his wont, Robin tends to squish them quickly and thorougly.

Utility, for me, has been great. It's allowed me to create a data-model-driven property-manipulation GUI system which I now use for all of my GUI work (save PyOpenGL, where I can't because it's not sure that people will have wxPython). Sure, I could do the same stuff with a custom control, but I never would have touched the project if I had to do that first :slight_smile: .

Enjoy yourself,
Mike

Ellers wrote:
<bug report copy deleted>

FWIW there has been mention on lots of problems with the grid control in the past... I don't know how useful it is at present.

Ellers

...

When you delete items from a wxGrid (using my recipe from the wiki), the
internal data structures don't seem to be updated.
Symptoms:

     The mouse cursor changes to "resize" over the places where the
grid-lines previously were.
     Clicking on any cell causes a call to the table's
GetAttr(row,call,extra) method. Since the internal data is likely gone,
this causes an assert.
     Trying to resize a grid-line causes an assert.

Which recipe? More specifically, do you have a simple sample I can use to
duplicate it?

BTW: www.wxPython.org is refusing my connection attempts this evening.

It's at SF so nearly anything could have been the reason.

Don't know why. Can't find the "submit a bug" link at wxwindows.org.

You can get to it directly via the wxWindows project page at SF:

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Recipe is here:
http://wiki.wxpython.org/index.cgi/wxGrid#line24

As for a simple sample, it's occuring in wxprop's sequence editors, which are hardly "simple" or easily minimisable out of their current context. I'll try to build one now.

...time passes...

Okay, as expected, happens with GridHugeTable in the demo. A (very hacked-up) version is attached. Choose test|trim from menu to trim the grid to a 2x2 window yet still see all the other cells alive and well (just invisible). For real fun, resize those cells and enjoy the magic of asserting :slight_smile: .

Enjoy,
Mike

Robin Dunn wrote:
...

Which recipe? More specifically, do you have a simple sample I can use to
duplicate it?

...

GridHugeTable.py (3.66 KB)

···

_______________________________________
   Mike C. Fletcher
   Why, yes, I am looking for a job...
   http://members.rogers.com/mcfletch/