[wxPython] Paint problems in windows

I just tried running my app in windows using wxPython 2.3 for
windows and found that the paint events are being handled very
strangely. My general layout is that I have a parent frame that
contains a wxPanel, and my derived class does some painting on the
wxPanel with a DC, so I have that done in onPaint. However, even
though the wxPanel registers the EVT_PAINT handler, it never gets
called (this works fine in linux). Also, I put an event handler in the
parent frame to check if it got the paint event and it receives it
multiple times. Any ideas on this weirdness? Is this a bug?

         -- Mike

···

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html

  I just tried running my app in windows using wxPython 2.3 for
windows and found that the paint events are being handled very
strangely. My general layout is that I have a parent frame that
contains a wxPanel, and my derived class does some painting on the
wxPanel with a DC, so I have that done in onPaint. However, even
though the wxPanel registers the EVT_PAINT handler, it never gets
called (this works fine in linux). Also, I put an event handler in the
parent frame to check if it got the paint event and it receives it
multiple times. Any ideas on this weirdness? Is this a bug?

One big difference between MSW and GTK is that if a wxPaintDC is not created
for a widnow that has a EVT_PAINT handler then MSW will send the message
again immediately assuming that it wasn't handled properly. So that is the
first thing to check. Make sure that your OnPaint makes a wxPaintDC for the
window even if it is not used.

···

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

Ok. That explains why the frame handler was called repeatedly. It
doesn't explain why the wxPanel never received the event, which was
the initial problem though.

             -- Mike

···

On Mon, Mar 18 @ 14:43, Robin Dunn wrote:

> I just tried running my app in windows using wxPython 2.3 for
> windows and found that the paint events are being handled very
> strangely. My general layout is that I have a parent frame that
> contains a wxPanel, and my derived class does some painting on the
> wxPanel with a DC, so I have that done in onPaint. However, even
> though the wxPanel registers the EVT_PAINT handler, it never gets
> called (this works fine in linux). Also, I put an event handler in the
> parent frame to check if it got the paint event and it receives it
> multiple times. Any ideas on this weirdness? Is this a bug?

One big difference between MSW and GTK is that if a wxPaintDC is not created
for a widnow that has a EVT_PAINT handler then MSW will send the message
again immediately assuming that it wasn't handled properly. So that is the
first thing to check. Make sure that your OnPaint makes a wxPaintDC for the
window even if it is not used.

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

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

`-> (robin)

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html

> I just tried running my app in windows using wxPython 2.3 for
> windows and found that the paint events are being handled very
> strangely. My general layout is that I have a parent frame that
> contains a wxPanel, and my derived class does some painting on the
> wxPanel with a DC, so I have that done in onPaint. However, even
> though the wxPanel registers the EVT_PAINT handler, it never gets
> called

Is the "derived class" the panel you speak of or a different class? Is it
possible that some other window is also a child of the frame and at the same
position and size as the panel? (Eventhough you see the panel a sibling can
affect it this way.)

If all else fails, reduce it to a minimal sample that shows the problem and
send it.

···

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

I have two classes, say d1 which is derived from wxPanel and d2
which is derived from wxFrame. d1 becomes a child of the wxFrame (or
rather, is contained in the frame). d2 receives the paint event and
but d1 does not. I'll see if I can draft up an example in the next
couple of days.

···

On Mon, Mar 18 @ 22:05, Robin Dunn wrote:

> > I just tried running my app in windows using wxPython 2.3 for
> > windows and found that the paint events are being handled very
> > strangely. My general layout is that I have a parent frame that
> > contains a wxPanel, and my derived class does some painting on the
> > wxPanel with a DC, so I have that done in onPaint. However, even
> > though the wxPanel registers the EVT_PAINT handler, it never gets
> > called

Is the "derived class" the panel you speak of or a different class? Is it
possible that some other window is also a child of the frame and at the same
position and size as the panel? (Eventhough you see the panel a sibling can
affect it this way.)

If all else fails, reduce it to a minimal sample that shows the problem and
send it.

--
Michael Gilfix
mgilfix@eecs.tufts.edu

For my gpg public key:
http://www.eecs.tufts.edu/~mgilfix/contact.html