[wxPython-users] Problem with device context program - doesn't
display what i want
Christopher Barker
Chris.Barker at noaa.gov
Mon Sep 18 15:32:26 PDT 2006
Jason Wang wrote:
> I realized that i
> didn't attach EVT_IDLE to OnIdle(), i attached the file to make sure i
> did everything correctly (it works :D)
you have to be very careful with Idle events: an idle event is called
whenever the event queue becomes empty -- that can be very, very often.
For example, as you move the mouse, there are mouse events, but if the
system processes them fast enough (mine does) then the queue becomes
empty with just about every event, before the next one fires.
Put a print statement in your Idle handler, and see what I mean.
With your code, get a kind of flashy mouse as it deal with all those
Idle events.
Why not just init your buffer in OnSize? that's the only time you need to.
If you're trying to keep it from being re-inited a bunch of times as the
Window is re-sizing, you need to (re) set a timer on each size event,
and only re-init the buffer after the time fires, so it will only happen
if there's a few milliseconds between events.
This is done in wx.lib.floatcanvas, and discussion and example code has
been posted here a few times.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the wxpython-users
mailing list