我在一台AMD64机器上使用SBCL for Linux。函数控制-测试生成一个带有画布和两个滑动刻度的窗口。滑块:上面滑块和前面滑块的变量应该分别绑定到上面的THETA和前面的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))))) 发布于 2012-12-22 06:44:29
请原谅,我似乎没有进行尽职调查,这个问题在3年前在以下位置得到了回答:http://permalink.gmane.org/gmane.lisp.ltk.user/329
答案是传递给:VARIABLE的名称实际上不会自动更新。我将LAMBDA表达式传递给:COMMAND关键字,而不是乱搞:VARIABLE;因此,下面的方法是正确的:
(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))))https://stackoverflow.com/questions/13897824
复制相似问题