Hi,
with-ltk plus :serve-event t is good for when you have a program that you want to be able to run at the same time as the repl, or other ltk programs. But you should generally have at least the widgets for the initial frame prepared and debugged. The with-ltk starts a new Tk process, and anything in the body can "see" that main window -- any event callbacks will also see the Tcl/Tk process, as well.
If you're at an even earlier stage in development, which it sounds like you are, you can just install a serve-event ltk directly into your repl:
* (start-wish) * (mainloop :serve-event t)
Now anything you type in the repl will "see" your running Tk gui. So you can do stuff like:
* (make-instance 'label :text "hello, tk") * (setf >>label *) * (pack >>label)
-Thomas
(Apologies if anyone sees this twice. I sent it with the wrong From line the first time, and it bounced from the list)
Date: Mon, 19 Nov 2012 18:10:40 +0100 From: jw@raven.inka.de To: ltk-user@common-lisp.net Subject: [ltk-user] Increamentally build the GUI?
Hello everybody,
I am trying to build my tk GUI incrementally. The SERVE-EVENT parameter seems to suggest that something like the following should be possible:
(defvar *frame*) (defvar *label-widget*)
(with-ltk (:serve-event t) (setf *frame* (make-instance 'frame)) (pack *frame*))
(with-ltk (:serve-event t) (setf *label-widget* (make-instance 'label :master *frame* :text "initial text")) (pack *label-widget* :side :left))
(with-ltk () ;; All initializations are already done, we just need to enter MAINLOOP )
But instead of a single toplevel containing both, the frame and the label, I get two separate toplevels. And none of those toplevels seem to contain the label widget. The output of the ps command shows, that two separate WISH processes are started, which obviously is not going to work.
Does anybody have an example of how to properly use the SERVE-EVENT parameter?
ltk-user site list ltk-user@common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user