wx.EVT_PAINT in wxGTK

Robin Dunn wrote:
> Schoenborn, Oliver wrote:
>> Hello, I'm running an app I'm building with wxPython on MS Windows,

whenever

>> a wxPanel is shown all the controls in it get a EVT_PAINT event, that's
>> expected behavior. However, running the same app with wxPython and

wxGTK on

>> SGI (Unix) shows that the event for each control is NOT generated when

the

>> panel is shown. Is this a well-known portability thing (i.e. the way I
>> implemented it probably works only on Windows, a portable

implementation

>> would be slightly different)? The crucial Python code is:

> ...

What is it you are trying to do? Robin's quite right, most of the
cross-platform issues that come up on this list have to do with
expecting a particular order of operations of when widgets are
refreshed, etc.

However, there is usually a way to accomplish what you want without
needing particular behavior. In my experience, the cross-platform
approach is usually cleaner code anyway.

Well, I have the equivalent of a property tree control, ie one side of the
window is a tree, the other half is a panel that shows a bunch of
properties. The panel is specific to whatever leaf of the left tree is
selected. Each control on a panel is associated with one attribute in a
document, e.g. density or mass. Each control should update what it shows
when it is repainted, not only the value but the color of the text, since
the attribute may have changed (due to the user having loaded a new
document, etc). Similarly, each control must commit a new value to its
associated attribute when the control is changed.

On MS I was just monitoring paint events: whenever a control was painted, it
would get the value from its associated attribute. Whenever the control was
changed (wx.EVT_TEXT), it would commit the new value to the associated
attribute.

Frankly, I'm sure this problem has been solved a zillion times, pitty there
isn't a documented solution to this.

The only other technique I can think of is publish/subscribe that Robin
mentioned in another thread a while back, but I'm a little wary of creating
a publisher for something that ought to be "heard" by only one event handler
object. The EVT_PAINT seemed the most natural.

But I'm open to suggestions.

Oliver