Moving a grid row while keeping its height

Hi,

I want to implement a wxGrid that can keep the height of the rows when
the rows are being moved. I checked the grid demo GridDragable.py in
the standard demo and find it has a bug.

In the demo, when you increase the height of the first row, then try
to drag this row to the last row, the following exception is raised:

Traceback (most recent call last):
  File "GridDragable.py", line 186, in OnRowMove
    self.GetTable().MoveRow(frm,to)
  File "GridDragable.py", line 150, in MoveRow
    grid.ProcessTableMessage(msg)
  File "/root/temp/wxPython-src-2.8.1.1/wxPython/wx/grid.py", line
1200, in ProcessTableMessage
    return _grid.Grid_ProcessTableMessage(*args, **kwargs)
wx._core.PyAssertionError: C++ assertion "uiIndex < m_nCount" failed
at /opt/wx/2.8/include/wx-2.8/wx/dynarray.h(813) in Item()

I'd like to know what exactly the code segment in the demo is trying to do:

            # Notify the grid
            grid.BeginBatch()
            msg = gridlib.GridTableMessage(
                    self, gridlib.GRIDTABLE_NOTIFY_ROWS_DELETED, frm, 1
                    )
            grid.ProcessTableMessage(msg)
            msg = gridlib.GridTableMessage(
                    self, gridlib.GRIDTABLE_NOTIFY_ROWS_INSERTED, to, 1
                    )
            grid.ProcessTableMessage(msg)
            grid.EndBatch()

Especially, what is a GridTableMessage and how does it impact on the
outlook of the grid? Can anyone give an explanation, since information
on this is hard to find.

Thanks!

···

--
Hong Yuan

大管家网上建材超市
装修装潢建材一站式购物
http://www.homemaster.cn

Yuan HOng wrote:

···

On 3/29/07, Robin Dunn <robin@alldunn.com> wrote:

Yuan HOng wrote:

> Especially, what is a GridTableMessage and how does it impact on the
> outlook of the grid?

It basically is just a way for the table (or some other part of the app)
to inform the grid (the view) that something has changed in the data
(the model) and that the grid should then do something to react to that
change such as refresh some cells, etc.

Thanks, I guess that is what it does. But what exactly? Particularly
in case of the bug I mentioned for the demo, what exactly goes wrong?
Must I read the wxWidgets C code to find out the problem? Seems the
error is with wxWidgets instead of wxPython from the trace, am I
right?

Try reversing the order of the delete and insert messages.

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