Discussion:
[Tkinter-discuss] Exit from method loop
Paul Simon
2013-04-09 03:52:43 UTC
Permalink
Hi All,

I've attaached code simplified from my "opus" and have a problem. I would
like to exit from "read_sensor" into the main loop. I cannot access the
"stop" check button or the "quit" button while the intenal loop in
"read_sensor" is running. The internal loop is intended to run continuously
until interrupted by the "stop" button but for demo purposes it is set to 10
interations.

Paul Simon


begin 666 focusset.py
M:6UP;W)T('1I;64*:6UP;W)T('-E<FEA; IF<F]M(%1K:6YT97(@:6UP;W)T
M("H*9VQO8F%L('H*9VQO8F%L(&-K"F1E9B!R96%D7W-E;G-O<BAE=F5N="DZ
M"B @("!G;&]B86P@>@H@(" @<75I=%]B=71T;VXN9F]C=7-?<V5T"B @("!R
M;V]T+G5P9&%T95]I9&QE=&%S:W,H*0H@(" @9F]R(&D@:6X@<F%N9V4@*#$P
M*3H*(" @(" @("!T:6UE+G-L965P*#$I"B @(" @(" @<')I;G0@(G)E861?
M<V5N<V]R(#T@(BQC:RYG970H*0H@(" @(" @('H])SXK,"XV,3,Y*S N-3DU
M-2LP+C8P.#0K,"XU-S8V*S K,"<*(" @(" @("!R;V]T+G5P9&%T95]I9&QE
M=&%S:W,H*0H@(" @(" @(&-O=6YT*&5V96YT*0H@(" @(" @('!R:6YT('H*
M"F1E9B!C;W5N=" H979E;G0I. at H@(&=L;V)A;"!Z"B @<F]O="YU<&1A=&5?
M:61L971A<VMS*"D*("!P<FEN=" B8V]U;G0@(#T@(BQC:RYG970H*0H@(&EF
M("AC:RYG970]/3$I. at H@(" @("!P<FEN=" B8V]U;G0R(#T@(BP at 8VLN9V5T
M*"D*"B @>CUZ+FQS=')I<"@G*SXG*2YR<W1R:7 H*2YS<&QI="@G*R<I"B @
M>2 ](%M="B @9F]R(&<@:6X@>CH*(" @('DN87!P96YD*#$P,"IF;&]A="AG
M*2D*"B @=&5X=%]B=71T;VXQ+F1E;&5T92 at Q+C L14Y$*2 @"B @=&5X=%]B
M=71T;VXQ+FEN<V5R="A%3D0L('E;,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T
M=&]N*&9R86UE+"!T97AT/2)154E4(BQF9STB<F5D(BP at 8V]M;6%N9#UR;V]T
M+F1E<W1R;WDI"G%U:71?8G5T=&]N+F=R:60H<F]W/3 L(&-O;'5M;CTT*0H*
I9G)A;64N<&%C:R at I(" @(" @( H@(" @"G)O;W0N;6%I;FQO;W H*0H`
`
end
Andreas Ostermann
2013-04-09 07:22:21 UTC
Permalink
Hi,

if it should loop continuously, why don't you put it into a background
thread?

Or, as you are using sleep() remove the loop and use root.after() to invoce
the check method every now and then...

brgds,

AO



2013/4/9 Paul Simon <psimon at sonic.net>
Post by Paul Simon
Hi All,
I've attaached code simplified from my "opus" and have a problem. I would
like to exit from "read_sensor" into the main loop. I cannot access the
"stop" check button or the "quit" button while the intenal loop in
"read_sensor" is running. The internal loop is intended to run continuously
until interrupted by the "stop" button but for demo purposes it is set to 10
interations.
Paul Simon
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20130409/73c66e1d/attachment.html>
Paul Simon
2013-04-11 03:58:52 UTC
Permalink
Andreas,

Thanks very much for the response to my question. Using threading is beyond my programming capability and since I am only occasionally programming would not be worth my time to learn. I'm not clear about the second suggestion you made and would appreciate some clarification.

At the moment my intuition is telling me that the sleep statement is the source of the problem, as it might interfere with the check button selection, and the rest of the loop is too fast to catch the "click." I'm going to replace "sleep" with a time delta construction and see if that works any better.

Paul
"Andreas Ostermann" <andreas.ostermann.11 at googlemail.com> wrote in message news:CANs6TN+p4YUcqzkrWnfwqaTKvC1_rp5vXhxsgOgKgFYCnUibLA at mail.gmail.com...
Hi,


if it should loop continuously, why don't you put it into a background thread?


Or, as you are using sleep() remove the loop and use root.after() to invoce the check method every now and then...


brgds,


AO





2013/4/9 Paul Simon <psimon at sonic.net>

Hi All,

I've attaached code simplified from my "opus" and have a problem. I would
like to exit from "read_sensor" into the main loop. I cannot access the
"stop" check button or the "quit" button while the intenal loop in
"read_sensor" is running. The internal loop is intended to run continuously
until interrupted by the "stop" button but for demo purposes it is set to 10
interations.

Paul Simon




_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss





------------------------------------------------------------------------------


_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss at python.org
http://mail.python.org/mailman/listinfo/tkinter-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tkinter-discuss/attachments/20130410/a9e334c2/attachment.html>
Loading...