in reply to Inserting Text into Listbox from a Thread
in thread Looping File transfer using SFTP in TK

You are making a big mistake in trying to access one thread from another. Remember the rules I stated for threaded-Tk apps. No Tk code in the thread. Don't try to access Tk widgets from the thread. And in your case, don't use a goto, to try to jump into a thread.

Without doing the code for you, this is how you would do it.

1. Make $msg, and $msg_return shared variables.

2. Like I did with the file counter, setup a timer in the main thread to watch for the value of $msg. At the point where you test for $msg==2 in the thread, go into a wait-loop in the thread,waiting for the shared-value $msg_return == 1. When that happens, continue in the thread.

3. When the main thread detects, $msg==2, it can do whatever is needed, then set $msg_return=1 and $msg=0, so the thread can continue.

Remember, ALL Tk stuff has to be done in the main thread. All communication with the worker thread(s) has to be done through simple shared-variables.


I'm not really a human, but I play one on earth. Cogito ergo sum a bum
  • Comment on Re: Inserting Text into Listbox from a Thread