[ltk-user] Handling radio-button values

Peter Herth herth at peter-herth.de
Thu Oct 4 13:25:55 UTC 2007


Hi Mirko,

to access the value of a radio button set, you use the value function.
It is of no importance, upon which button widget you call it as long
as it is in the same set (means: those radio buttons which share the
same variable). To illustrate I rewrote your example code:

(defun radio-button-minimalist ()
  (with-ltk()
    (let* ((gender-frame (make-instance 'frame :master nil))
	   (lbl_gender (make-instance 'label
				      :master gender-frame
				      :text "Sex "))
	   (rdb_m (make-instance 'radio-button
				 :master gender-frame
				 :text "Male"
				 :variable "gender"
				 :value "Male"))
	   (rdb_f (make-instance 'radio-button
				 :master gender-frame
				 :text "Female"
				 :variable "gender"
				 :value "Female"))
           (text (make-instance 'text
			       :master nil
			       :width 20
			       :height 10))
	   (but (make-instance 'button
			       :master nil
			       :text "Push me"
			       :command (lambda ()
                                          (setf (text text)
                                                (format nil "The value
of radio-button is: ~a" (value rdb_m))))
                               ))
	   )
      (setf *radio-button-minimalist* `(:text ,text))
      (grid gender-frame 1 1)
      (grid lbl_gender 1 1)
      (grid rdb_m 1 2)
      (grid rdb_f 1 3)
      (grid but 2 1 :columnspan 2)
      (grid text 3 1 :columnspan 2))))


Peter



More information about the ltk-user mailing list