Version française
Home     About     Download     Resources     Contact us    
Browse thread
LablTk problem
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@k...>
Subject: Re: LablTk problem
From: wester@ilt.fhg.de

> Sorry it was my fault, I found the problem. I simplified things a 
> little bit in the above example. The program as it is works fine. 
> But when I was testing the program I made the following:
> 
> Thread.start Tk.mainLoop();;
> 
> And now the menus don't work any more. What I want to do is start 
> a Tk application in it's own thread and  be able to draw to the canvas 
> interactively  at the sam time. If I press one the simple buttons the 
> application stops, only the menus don't work.

We are sorry, but ocamltk and labltk are not reentrant, so you cannot
use threads with them. Having a thread running the Tk mainloop and all
Tk calls and callbacks, while all other threads do some other work
seems to be safe (I actually use it in the Win32 version of
ocamlbrowser), but as soon as you call Tk functions in other threads
you're dead.

On Unix, Tcl/Tk provides two kinds of callbacks that may help you do
thread-like work: timeouts (module Timer) and fileinputs (module
Fileevent). They allow you to program in a non-blocking
way. Unfortunately, fileinputs do not seem to work on windows.

If you really want to use threads, you should look at lablgtk, which
is reentrant, and allows any kind of funny thing you might want to do
with threads.

Jacques Garrigue
---------------------------------------------------------------------------
Jacques Garrigue      Kyoto University     garrigue at kurims.kyoto-u.ac.jp
		<A HREF=http://wwwfun.kurims.kyoto-u.ac.jp/~garrigue/>JG</A>