Push to Make (Single Pole) Button running a loop

Hendrik van Rooyen mail at microcorp.co.za
Mon Dec 31 02:33:53 EST 2007


 "Jon Todd" <jo...en.co.uk> wrote:

>I'd like to have a button that when pressed executes a loop (this could be a
>thread) and then stops execution when it's released (Push to Make - Single
>Pole in electronics terms).
>
>I've tried the regular way of associating the procedure with a callback and
>tried using <Button-1> and <ButtonRelease-1> bindings but am getting nowhere
>fast (in the latter case the button release event seems to occur anyhows).
>

You are a bit stymied :

Afaik, Button needs the click on the button, leaving it depressed,
while ButtonRelease needs a click on the button, and the release can be anywhere
for drag and drop implementation.  So it is possible to call two routines with
one
click and release.

But there is another hassle - you would have to code the loop as a separate
thread,
started by the first, while the second routine sets some variable that is
checked by
the loop to kill itself, as the GUI will not be responsive until the first
command
returns, because the command "captures" the main loop...

HTH - Hendrik





More information about the Python-list mailing list