Page 1 of 1

ltk

PostPosted: Tue Dec 25, 2018 4:09 am
by saufesma
Hello there,

I cannot figure out how to update variable s when clicking button "Sum"

Code: Select all
(in-package :ltk)
(defun string-to-number (n)
  (car (list (read-from-string n))))

(defun sum (a b)
  (+ (string-to-number a) (string-to-number b)))

(defvar s)
(setq s 0)

(defun ltksum()
  (with-ltk ()
    (let* ((bar (make-instance 'frame))
      #-:tk84
      (e1 (make-instance 'entry :master bar))
      (e2 (make-instance 'entry :master bar))
      (b4 (make-instance 'button
               :master bar
               :text "Sum"
               :command (lambda ()
                (setf s (sum (text e1) (text e2))))))
      (l (make-instance 'label
              :master bar
              :text s)))
(pack bar)
(pack e1 :side :left)
(pack e2 :side :left)
(pack b4 :side :left)
(pack l :side :left)
)))