[wxPython] wxGrid Refresh on Linux

Hi all,

This has come up before, but the posted answers don't do the trick for
me.

I have a splitter window with a couple of wxGrid-derived panes.

When the keyboard focus changes from one pane to the other, I want to
change the background color so the user knows where the focus is.

So I change the default background color, and then call Refresh.

Works fine on M$. On Linux, Refresh doesn't repaint until the window
is resized, or hidden and re-exposed, or something.

Robin previously posted the below code snippet as a solution for this;
requires creating your own DoDraw method. BUT I'm not doing the
drawing myself, and wxGrid doesn't expose any kind of paint or draw
method besides Refresh.

Any thoughts? I'd settle for changing the color of keyboard cursor, or the
grid lines -- but I couldn't find anything that changed the cursor
color, and I think the gridlines need Refresh, too.

Robin said:
    def OnPaint(self, evt):
        dc = wxPaintDC(self)
        self.DoDraw(dc)

    def MyRefresh(self):
        dc = wxClientDC(self)
        self.DoDraw(dc)

    def DoDraw(self, dc):
        # do the actual drawing here...

By the way, this is wxPython 2.2.5...

···

Hi all,
This has come up before, but the posted answers don't do the trick for
me.

I have a splitter window with a couple of wxGrid-derived panes.

When the keyboard focus changes from one pane to the other, I want to
change the background color so the user knows where the focus is.

So I change the default background color, and then call Refresh.

Works fine on M$. On Linux, Refresh doesn't repaint until the window
is resized, or hidden and re-exposed, or something.

Robin previously posted the below code snippet as a solution for this;
requires creating your own DoDraw method. BUT I'm not doing the
drawing myself, and wxGrid doesn't expose any kind of paint or draw
method besides Refresh.

Any thoughts? I'd settle for changing the color of keyboard cursor, or the
grid lines -- but I couldn't find anything that changed the cursor
color, and I think the gridlines need Refresh, too.

Robin said:
    def OnPaint(self, evt):
        dc = wxPaintDC(self)
        self.DoDraw(dc)

    def MyRefresh(self):
        dc = wxClientDC(self)
        self.DoDraw(dc)

    def DoDraw(self, dc):
        # do the actual drawing here...

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwindows.org
http://lists.wxwindows.org/mailman/listinfo/wxpython-users

I found a horrible hack that solves this. I make my grid's
PyGridTableBase send a wxGRIDTABLE_REQUEST_VIEW_GET_VALUES message to
my grid after calling Refresh. Refreshes nicely, Linux or Windows.

I've had a look at the C++ but don't immediately see a way to do this
more directly via the existing interfaces.

class MatchGrid(wxGrid):
.....
    def MyRefresh(self):
        self.Refresh()
        self.table.GridDataUpdated()

class MatchDataTable(wxPyGridTableBase):
.....
    def GridDataUpdated(self):
        debug("MatchDataTable GridDataUpdated")
        msg = wxGridTableMessage(self,
                                 wxGRIDTABLE_REQUEST_VIEW_GET_VALUES,
                                 1)
        self.GetView().ProcessTableMessage(msg)

···

Hi all,
This has come up before, but the posted answers don't do the trick for
me.

I have a splitter window with a couple of wxGrid-derived panes.
So I change the default background color, and then call Refresh.

Works fine on M$. On Linux, Refresh doesn't repaint until the window
is resized, or hidden and re-exposed, or something.

Robin previously posted the below code snippet as a solution for this;
requires creating your own DoDraw method. BUT I'm not doing the
drawing myself, and wxGrid doesn't expose any kind of paint or draw
method besides Refresh.

This has come up before, but the posted answers don't do the trick for
me.

Different problem, I think.

I have a splitter window with a couple of wxGrid-derived panes.

When the keyboard focus changes from one pane to the other, I want to
change the background color so the user knows where the focus is.

So I change the default background color, and then call Refresh.

Works fine on M$. On Linux, Refresh doesn't repaint until the window
is resized, or hidden and re-exposed, or something.

The wxGridWindow is actually composed of 4 windows in addition to the
wxScrolledWindow. (One of the row labels, the column labels, the little bit
in the corner, and for the grid itself.) Apparently calling Refresh on the
parent has different effects on the children on the different platforms, and
until 2.3.0 there was no way to get at the component windows without
upgrading. (If you did you could do grid.GetGridWindow().Refresh())

New in 2.3.1 is a ForceRefresh() method, which is simple implemented as:

    grid.BeginBatch()
    grid.EndBatch()

which looks like it should work in 2.2.x as well. Give it a try.

···

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