linux - Lisp 工具包 (ltk) : Cannot get SCALE :variable value

标签 linux common-lisp x86-64 sbcl ltk

我正在 AMD64 计算机上使用适用于 Linux 的 SBCL。 函数 CONTROL-TEST 创建一个带有绘图 Canvas 和两个滑动比例尺的窗口。 slider :VARIABLES for UPPER-SLIDER 和 FORE-SLIDER 应该分别绑定(bind)到 UPPER-THETA 和 FORE-THETA,但是更新代码除了 0 之外看不到任何东西。我已经在另一个函数中测试了更新代码。

(defun controltest ()
  "Test of a user-controlled robot arm"
  (with-ltk ()
    ; (make-instance 'scale :master fscale :from 0 :to 100  :length 150 )
    (let* ((upper-theta 0) (fore-theta 0)
       (upper-slider 
        (make-instance 'scale :from 0 :to 7 
               :length  360 :variable upper-theta))
       (fore-slider 
        (make-instance 'scale :from 0 :to 7
               :length  360 :variable fore-theta))
       (cnvs (make-instance 'canvas :width cnvs-width :height cnvs-height))
       (upper (manip:uctk-beam :cen-x 200 :cen-y 200 
                   :b-length 40 :b-width 20
                   :tk-cnvs cnvs))
       (fore (manip:uctk-beam :cen-x 0 :cen-y 40 ; relative to upper
                  :b-length 40 :b-width 20
                  :tk-cnvs cnvs))
       (slp-time 50))
      (labels ((update ()
         (draw upper nil) ; contains FORE, no need to draw separately
         (geo:set-member-theta upper 2 fore-theta)
         (geo:set-theta upper upper-theta)
         (after slp-time #'update)))
    (geo:add-geo upper fore) ; make FORE a member of UPPER
    (pack cnvs :fill :both :expand 1)
    (pack upper-slider :side :bottom)
    (pack fore-slider :side :bottom)
    (update))))) 

最佳答案

请原谅,看来我没有尽职调查,这个问题 已于 3 年前在以下位置得到答复: http://permalink.gmane.org/gmane.lisp.ltk.user/329

答案是传递给 :VARIABLE 的名称实际上并未更新 自动地。我没有乱搞 :VARIABLE,而是将 LAMBDA 表达式传递给 :COMMAND 关键字;因此以下是正确的方法:

(upper-slider 
        (make-instance 'scale :from 0 :to 7 
               :length  360 
               :command (lambda (val) (setq upper-theta val))))
(fore-slider 
        (make-instance 'scale :from 0 :to 7 
               :length  360 
               :command (lambda (val) (setq fore-theta val))))

关于linux - Lisp 工具包 (ltk) : Cannot get SCALE :variable value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13897824/

相关文章:

c - 从 xmm 寄存器中提取数据到 'standard' 变量,内在

assembly - 将常量字节值移动到 %ebx 时出错

linux - 从shell中的json中提取特定元素的值

list - 生成组合

lisp - 在 LISP 中使用 dolist 反转列表

json - 使用 drakma :http-request 发布 JSON 数据

c++ - 如何使用 qmake 在 Windows 64 位上链接到 ACML?

linux - 如何多次匹配内部模式而不是相似的外部模式?

c - 在 Linux 内核中,进程为 "whole"是什么意思?

c++ - gcc 链接的默认库?