[wxpython-users] How to detect inactivity?
Christopher Barker
Chris.Barker at noaa.gov
Thu May 15 11:26:47 PDT 2008
> in the keyboard/mouse eventhandlers:
> self.UserDidSomething = True
> event.Skip()
This is the tricky part -- I don't like that you need to add this code
to all event handlers. IN fact, more than that! You now need to write
handlers for ALL events, even if you don't have anything custom to do in
them.
I wonder is you could use EVT_IDLE -- it gets fired whenever the event
queue gets empty -- which happens a lot. Usually, when the user does
something, a bunch of events fill the event queue, they get processed,
and then the queue is empty again, and EVT_IDLE gets fired.
So, you could catch EVT_IDLE, start your timer there, and reset it
every time you get an EVT_IDLE. If there is no activity, there should be
no more EVT_IDLE's and if that happens for ten minutes, you're done.
Issues:
the timer events may trigger EVT_IDLE -- so that could mess things up
If there is a LOT of activity, the event queue may never be empty, but
it's hard to see that happening for ten full minutes.
> You can watch for mouse and keyboard events in a handler
> bound to the app object.
Do all events propagate to the app object? I didn't think so.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (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