ltk

Discussion of other useful tools

ltk

Postby saufesma » Tue Dec 25, 2018 4:09 am

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)
)))
Last edited by nuntius on Tue Dec 25, 2018 7:32 pm, edited 1 time in total.
Reason: add code tags
saufesma
 
Posts: 5
Joined: Tue Dec 18, 2018 1:38 am

Return to Other Tools

Who is online

Users browsing this forum: No registered users and 1 guest

cron