Do the same EVT_ERASE_BACKGROUND trick for the panel as you do for the
frame. Or use self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) instead.
--
Robin Dunn
Software Craftsman
http://wxPython.org
Hello All,
Attached is a small app that may be useful to others who don't like to re-invent the wheel !
...
Dominique
Hello All,
Attached is a small app that may be useful to others who don't like to re-invent the wheel !
It shows a gradient panel with some StaticTexts.
The problem with static texts and a gradient panel is that they usually appear with a rectangle of a different colour than the panel background.
So, the final result is not as nice as it could be.
Consequently, I think the example I give avoids this problem, although it is not perfect.
In the OnPaint method, I get the colour of the pixel located in the middle of the static text.
And I set the background colour of the static text to this average value.
It works well on Mac.
> Do the same EVT_ERASE_BACKGROUND trick for the panel as you do for
> the frame. Or use self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) instead.
>
>
> --
> Robin Dunn
> Software Craftsman
> http://wxPython.org <http://wxpython.org/>
>
> What kind of magic is this ?! (OK, I borrowed this line from a certain
> movie.)
> Why does hooking into the event, doing absolutely nothing extra and then
> passing on the event processing do, exactly ?
By catching the event and not calling Skip then you are preventing the
default handler for the event from being called. In this case that
default handler is erasing the background, which is a major cause of
flicker if your paint handler is just going to fill the whole window
with something else. (First you see the cleared background, then you
see the painted window. TaDa! Flicker.)
> Does this work on all platforms or just MSW ?
MSW is usually the only one that needs it. In normal situations the
erase background event is simulated on the other platforms anyway, it's
not a separate event coming from the system.