I don't believe it's true that you can only have Tk in one thread.  It's been a while but I'm about 90% sure that I have some applications that use Tk in every thread.  You will get a toplevel window for each thread you use it in, though.

thread::wait or vwait will work to stay in the event loop, there are probably other techniques also.  But the basic idea is, you have to give it somewhere to wait, otherwise it's going to fall through and exit.  The same is true for many event-loop based programming languages.

On 11/1/2011 4:36 PM, Duquette, William H (318K) wrote:
Howdy!

Two questions:

1. I know that I can only use Tk in a single thread of a multi-threaded app.  Does it matter which thread it is, i.e., if Tk is NOT running in the main thread is it OK to invoke it in a thread created using thread::create?

(I've tried it; it appears to work; I just need to know whether it will cause me problems in the long run.)

2.  When I invoke Tk using [package require Tk] in a thread created using thread::create, it appears that I have to call [vwait] or [thread::wait] explicitly at the end of the thread startup script, or I don't enter the event loop.  Is this expected behavior?

Thanks very much!

Will
--
Will Duquette -- William.H.Duquette@jpl.nasa.gov
Athena Development Lead -- Jet Propulsion Laboratory
"It's amazing what you can do with the right tools."



------------------------------------------------------------------------------
RSA® Conference 2012
Save $700 by Nov 18
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev1


_______________________________________________
Tcl-Threads mailing list
Tcl-Threads@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tcl-threads