2009/12/6 Peter Herth herth@peter-herth.de:
On Sun, Dec 6, 2009 at 2:03 AM, Greg Bennett gwbennett@sentex.ca wrote:
My lisp experience is with Franz's Allegro and their common graphics. There I can open a window and keep the listener/repl alive. From the repl (setf w make-a-window-syntax) then allows me to do things like (draw-to w some-graphic) from that REPL. This facility is important to the application I'm interested in porting; I guess it means that I must learn how to program with threads/processes to obtain this behaviour.
First of all - you can interactively call start-wish to start a wish session and then use all LTk-functions from the repl (you will get events handles only if you call process-events or mainloop). However this is only for testing and interactive development.
If you want to have a lisp repl within a LTk program, I would not recommend threads. Amongst all other possible problems, the LTk functionality should be used only from one thread. But fortunately, this is not necessary if you want for example just integrate a lisp listener into a LTk program. The easiest solution would be, to use a textfield for the repl interaction and trigger the Lisp evaluation from the corresponding Tk events - no threads needed. ABLE implements a small Lisp IDE completely in LTk.
I just have a few things to add to what Peter said:
* Regarding threads, Ltk is most certainly not reentrantly thread-safe. It's in a situation like Apple's Cocoa is/was; you may have multiple threads, but only one may control the GUI. Changing this isn't especially a priority as in practice it's never been a problem.
* I agree that an Ltk-based REPL would be the right answer if it's to be part of an application. But there is another, SBCL-specific way to launch an Ltk program and keep the REPL responsive. You can tell Ltk to integrate itself into the SBCL main event loop by doing (with-ltk (:serve-event t) ...).
I added the serve-event backend precisely to be able to interact with the running gui without having to call (mainloop) manually :-)
-Thomas