I am having two problems with SCALE.
1. I cannot set bounds to anything other than integers. For example: (make-instance 'scale :from 0 :to (* 2 pi) ... gives me an error.
2. I am unable to retrieve the :VARIABLE value
In the below, vales of UPPER-THETA and FORE-THETA never seem to be anything but 0, no matter where I slide the scale. I have tested all the drawing an update code, I am stumped!
(defun controltest () "Test of a user-controlled robot arm" (with-ltk () (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) #|ms|# ) (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)))))
JW <james.robert.watson <at> gmail.com> writes:
I am having two problems with SCALE.
- I cannot set bounds to anything other than integers. For example:
(make-instance 'scale :from 0 :to (* 2 pi) ... gives me an error.
- I am unable to retrieve the :VARIABLE value
In the below, vales of UPPER-THETA and FORE-THETA never seem to be anything
but
0, no matter where I slide the scale. I have tested all the drawing an update code, I am stumped!
(defun controltest () "Test of a user-controlled robot arm" (with-ltk () (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) #|ms|# ) (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)))))
Please excuse me, it appears I did not perform my due diligence, this question was answered 3 years ago at the following location: http://permalink.gmane.org/gmane.lisp.ltk.user/329
The answer is that the name passed to :VARIABLE is not in fact updated automatically. Instead of messing with :VARIABLE, I pass a LAMBDA expression to the :COMMAND keyword; and therefore the following is the correct way:
(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))))