[ltk-user] *wish* global

Shawn Betts sabetts at vcn.bc.ca
Sun Jun 24 03:18:54 UTC 2007


Hi Peter,

Sorry for the delay. I'll try to illustrate what I'm doing and my
problem without quoting a bunch of irrelevant source code:

(defun do-rad-things ()
  (ltk:do-msg "activity from network!"))

(defun start-network ()
  (let ((socket-stream (....))
        (wish ltk:*wish*))
    (sb-ext:add-fd-handler socket-stream
                           (lambda ()
                             (let ((ltk:*wish* wish))
                               'do-rad-things)))))

(defun start ()
  (ltk:with-ltk (:serve-event t)
    (build-our-gui)
    (start-network)))

When tk sends output to ltk, the ltk handler is called and
ltk:*wish* is bound to the poper wish structure. But when
do-rad-things is called, ltk:*wish* is no longer bound to the
proper wish structure so I have to do a little let dance to keep
it in order.

I propose that instead of a with-ltk macro, an ltk:root class is
created which holds the connection to the subprocess and
represents the default root window wish produces when you start
it. It would probably be most convenient if all other widgets
also carried a pointer to the wish subprocess or the root class.

So then the above might look like this:

(defun do-rad-things (wish)
  (ltk:do-msg wish "activity from network!"))

(defun start-network (wish)
  (let ((socket-stream (....))
    (sb-ext:add-fd-handler socket-stream
                           (lambda ()
                             (do-rad-things wish)))))

(defun start ()
  (let ((wish (make-instance 'ltk:root)))
    (build-our-gui wish)
    (start-network wish)))

What do you think?

-Shawn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/ltk-user/attachments/20070623/553876df/attachment.html>


More information about the ltk-user mailing list