Why is it that the EVT_IDLE only triggers when the mouse is moving? this
seems *very* weird, as surely that's when the gui is *not* idle...
What I'm looking for is a way to trigger a process whenever the gui's
not doing anything else, and EVT_IDLE looks like the way to go, but it
doesn't seem to work unless I move the mouse...
Why is it that the EVT_IDLE only triggers when the mouse is moving? this
seems *very* weird, as surely that's when the gui is *not* idle...
What I'm looking for is a way to trigger a process whenever the gui's
not doing anything else, and EVT_IDLE looks like the way to go, but it
doesn't seem to work unless I move the mouse...
any ideas? am i perhaps using the wrong EVT type?
If I recall correctly, IdleEvents are fired as long as some event recipient keeps calling event.RequestMore(). Once that doesn't happen, the idle system shuts down since there are no more idle tasks to run. A few things wake the idle system back up, among them moving the mouse. So, I think you want something like this.
# ....
def StartTasks(self):
wxWakeUpIdle()
def OnIdle(self, event):
# Do some stuff
event.RequestMore()
#....
Why is it that the EVT_IDLE only triggers when the mouse is moving? this
seems *very* weird, as surely that's when the gui is *not* idle...
Read the docs a bit more closely. The EVT_IDLE event is only sent when the event queue *becomes* empty, not continuously (unless you ask for more.) Otherwise the program would comsume all CPU (repeatedly looking for EVT_IDLE handlers) even when it is sitting there doing "nothing."
What I'm looking for is a way to trigger a process whenever the gui's
not doing anything else, and EVT_IDLE looks like the way to go, but it
doesn't seem to work unless I move the mouse...
any ideas? am i perhaps using the wrong EVT type?
You can call RequestMore as has been suggested already by Tim, but as I said if you always call RequestMore then you will use a lot of the CPU...
Another approach would be to do your thing in the EVT_IDLE handler and instead of calling RequestMore set a one-shot timer whose handler calls wxWakeUpIdle. (Technically that's not needed since the timer event itself will cause the idle handler to be woken up, but it's a good way to document why you have the timer...) Then another EVT_IDLE will be sent if the application is truley idle.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
Wow, until this very moment the wording had escaped me. When the event
queue BECOMES empty... I've been bugged by that for eons, it seems. I
see the light!
···
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Saturday, July 12, 2003 20:06
To: wxPython-users@lists.wxwindows.org
Subject: Re: [wxPython-users] EVT_IDLE issues..
Importance: High
Thomas CLive Richards wrote:
> hi,
>
> Why is it that the EVT_IDLE only triggers when the mouse is moving?
> this seems *very* weird, as surely that's when the gui is *not*
> idle...
Read the docs a bit more closely. The EVT_IDLE event is only
sent when
the event queue *becomes* empty, not continuously (unless you ask for
more.) Otherwise the program would comsume all CPU
(repeatedly looking
for EVT_IDLE handlers) even when it is sitting there doing "nothing."
>
> What I'm looking for is a way to trigger a process whenever
the gui's
> not doing anything else, and EVT_IDLE looks like the way to
go, but it
> doesn't seem to work unless I move the mouse...
>
> any ideas? am i perhaps using the wrong EVT type?
You can call RequestMore as has been suggested already by
Tim, but as I
said if you always call RequestMore then you will use a lot
of the CPU...
Another approach would be to do your thing in the EVT_IDLE
handler and
instead of calling RequestMore set a one-shot timer whose
handler calls
wxWakeUpIdle. (Technically that's not needed since the timer event
itself will cause the idle handler to be woken up, but it's a
good way
to document why you have the timer...) Then another EVT_IDLE will be
sent if the application is truley idle.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail:
wxPython-users-help@lists.wxwindows.org