Best way to kill a thread started from a TkButton push

J

Jason Tahaney

Hello all,

Looking for the best way to kill a thread started from
a TkButton push.

I'm just using one thread that I would like to control
via a Tk Start button and a Tk Stop button.

The reason for the question is that I'm using a method
called stop_thread that takes the thread to stop as
it's argument and simply using thread.kill, and
setting my button states back to normal ; This for the
most part works except when I call it from code as
opposed to from a user event. The button states do
not go back to normal for some reason when I call
stop_thread from code.

BTW it's the tk8.3 lib on win32.

Thanks in advance,

Jason

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 
J

John Johnson

Jason said:
Hello all,

Looking for the best way to kill a thread started from
a TkButton push.

I'm just using one thread that I would like to control
via a Tk Start button and a Tk Stop button.

The reason for the question is that I'm using a method
called stop_thread that takes the thread to stop as
it's argument and simply using thread.kill, and
setting my button states back to normal ; This for the
most part works except when I call it from code as
opposed to from a user event. The button states do
not go back to normal for some reason when I call
stop_thread from code.

BTW it's the tk8.3 lib on win32.

I can't help with your problem exactly, but this sounds like it is to do
with the Binding of the variable(s).
See the Pickaxe book: http://www.rubycentral.com/book/ext_tk.html

An excerpt:
"One small caution when using the code block form: the scope of
variables is not what you think it is. The block is actually evaluated
in the context of the widget's object, not the caller's. ..."

Regards,
JJ
 
J

Jason Tahaney

John said:
I can't help with your problem exactly, but this sounds like it is to do
with the Binding of the variable(s).
See the Pickaxe book: http://www.rubycentral.com/book/ext_tk.html

An excerpt:
"One small caution when using the code block form: the scope of
variables is not what you think it is. The block is actually evaluated
in the context of the widget's object, not the caller's. ..."

Regards,
JJ

Thanks, you got me thinking about the scope and it ended up being just
that, the scope awareness caution excerpt you provided from the pickaxe
book.

Regards,

Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top