wxGrid, wxGridTableBase, and cells spanning multiple columns

Hi everyone,
I would like to use wxGrid with a wxGridTableBase to display data ranging
into tens of thousands of rows with multiple columns.

Occasionally, I want one of the rows to have only one cell spanning the
entire width of the grid, so that a title can be displayed as a way to
separate groups of rows.

I solved this problem by storing a reference to the grid in the table
object, intercepting the GetValue( ) calls into the table object, and
calling grid.SetCellSize( ... ) as needed based on the row.

However, the display gets messed up when it is scrolled because the control
always draws grid lines for all the columns and GetValue() is called only
after a certain amount of the row is displayed. The result is that partial
vertical grid lines appear where not wanted.

I got rid of this problem by disabling grid lines, but I would like to have
grid lines. Is there a way to do this?

-Rick King

Rick King wrote:

Hi everyone,
I would like to use wxGrid with a wxGridTableBase to display data ranging
into tens of thousands of rows with multiple columns.

Occasionally, I want one of the rows to have only one cell spanning the
entire width of the grid, so that a title can be displayed as a way to
separate groups of rows.

I solved this problem by storing a reference to the grid in the table
object, intercepting the GetValue( ) calls into the table object, and
calling grid.SetCellSize( ... ) as needed based on the row.

However, the display gets messed up when it is scrolled because the control
always draws grid lines for all the columns and GetValue() is called only
after a certain amount of the row is displayed. The result is that partial
vertical grid lines appear where not wanted.

I got rid of this problem by disabling grid lines, but I would like to have
grid lines. Is there a way to do this?

You may be able to work around it by requesting that the grid refresh that value. I think that it will also redraw it and the grid lines at the same time. After you do you SetCellSize then do something like this:

  msg = wxGridTableMessage(table,
        wxGRIDTABLE_REQUEST_VIEW_GET_VALUES,
        row, col)
  grid.ProcessTableMessage(msg)

Be sure to guard against endless recursion as I expect that sending this message will do another GetValue...

···

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

>
> However, the display gets messed up when it is scrolled because the

control

> always draws grid lines for all the columns and GetValue() is called

only

> after a certain amount of the row is displayed. The result is that

partial

> vertical grid lines appear where not wanted.

There seems to be a problem with wxGrid that causes the control to always
display column separator lines even though the grid there is defined as a
single cell spanning multiple columns. This only occurs when drawing a
*partial* row at the bottom.

The same thing does not occur when scrolling up.

This is on Windows XP and wxPython 2.4.1.2.

I attached a modified GridCustTable.py file that can be popped into the demo
to demonstrate it.
-Rick King

Rick King wrote:

However, the display gets messed up when it is scrolled because the

control

always draws grid lines for all the columns and GetValue() is called

only

after a certain amount of the row is displayed. The result is that

partial

vertical grid lines appear where not wanted.

There seems to be a problem with wxGrid that causes the control to always
display column separator lines even though the grid there is defined as a
single cell spanning multiple columns. This only occurs when drawing a
*partial* row at the bottom.

The same thing does not occur when scrolling up.

This is on Windows XP and wxPython 2.4.1.2.

I attached a modified GridCustTable.py file that can be popped into the demo
to demonstrate it.

There was no attachment...

···

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