QTimer and PyQt

Adrian Casey news at outbacklinux.com
Tue Jul 20 07:41:27 EDT 2004


I'm using a QTimer object to expire certain password protected GUI options
in my application after 2 minutes.  Currently, the timer is reset each time
the user presses the 'OK' button.  This is not ideal.  A user may spend 2
minutes entering data into the GUI before pressing OK in which case the
timer expires before they have pressed OK.

I want the timer to timeout after 2 minutes of keyboard inactivity (i.e. no
events sent) instead of 2 minutes following the last 'OK' click.

I can imagine 2 ways to do this -:

1.  Reset the timer (timer.stop(), timer.start()) each time a keystroke
event is received
  -- or --
2.  At timeout, check if any fields have changed (using the isChanged()
method.) and if so, reset the timer.

The problem is, I don't know how to do either in PyQt!  I think option 2
would be more efficient.  Is it possible to check the parent widget for any
changes to child widgets or do I have to iterate over each widget on the
form, checking each indivually?

Cheers.
Adrian.



More information about the Python-list mailing list