I have a listbox that needs to be updated periodically by a separate
thread. However, I am having trouble figuring out how to make that
happen. This code fails with a stream error, probably because the wish
stream is not accessible to the spawned thread:
(ltk:with-ltk (:debug 3)
(let* ((update-threads nil)
(f (make-instance 'ltk:frame))
(m1 (ltk:make-menubar))
(mf (ltk:make-menu m1 "File"))
(call-queue-listbox
(make-instance 'ltk:listbox :name "call_q"
:master f :width 30 :height 12))
(exit-fn #'(lambda ()
(setq *shutdown-gui* t)
(dolist (thread update-threads)
(join-thread thread))
(setq update-threads nil)
(setf ltk:*exit-mainloop* t)))
(mf-exit (ltk:make-menubutton mf "Quit" exit-fn)))
(ltk:pack f)
(ltk:grid call-queue-listbox 0 0)
(ltk:bind ltk:*tk* "<Alt-q>"
(lambda (event)
(declare (ignore event)) (funcall exit-fn)))
(push (make-thread
#'(lambda ()
(loop until *shutdown-gui*
do
(ltk:listbox-clear call-queue-listbox)
(dotimes (i (random 10))
(ltk:listbox-append
call-queue-listbox
(format nil "call ~A in queue" i)))
(sleep 1))))
update-threads)))
Can someone show me the correct ltk idiom for this?
Thanks!
-Kevin