Hello group,
I am having touble figuring out how to build widgets that handle button & slider events. I am going though the examples on this web site (http://www.bin-co.com/tcl/tutorial/widgets3.php).
I have attached a minimalist radio-button example that is supposed to transfer the value of the radio-button to the text field. The way it works is that I am supposed to choose the gender (male/female), and then press a button to transfer the gender to the text field.
The gender is predefined as male, so you need to press the female one, to get female in the text field. But that is not what happened.
I looked at the eggs example in lisp.ltk, where the button variable seems to refer to a function that produces textual output. I tried to emulate that as well, but not successfuly.
As a side note, I am planning to re-formulate all the examples on the above mentioned web page in ltk, and then look for a web site where to post them (Peter's would be a good choice). Of course, I would first look for suggestions for improvement from this group. The write up would be geared to lisp & ltk novices (which describes me pretty well).
Thanks,
Mirko
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
Peter,
thank you very much for your help. I am travelling now, and I will try to use what you showed me when I get back home
Mirko
On 10/4/07, Peter Herth herth@peter-herth.de wrote:
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 _______________________________________________ ltk-user site list ltk-user@common-lisp.net http://common-lisp.net/mailman/listinfo/ltk-user