How can I get Ltk to display what the user is writing and what the functions are printing out?

Function types are:

(defun display-all ()
  "Display all items in the database."
  (dolist (item *database*)
    (format t "~{~a:~10t~a~%~}~%" item)))

(defun prompt-read (prompt)
  (format *query-io* "~a: " prompt)
  (force-output *query-io*)
  (read-line *query-io*))

(defun prompt-for-item ()
  (make-database
   (prompt-read "Name")
   (prompt-read "Price")))

      

I have read the Ltk documentation but there seem to be no examples of using text widgets.

+1


source to share


1 answer


You create a text widget like any other widget. The Lisp -side object has text

a write method accessor that sets the text on the Tk side. Minimal example:



(with-ltk ()
  (let* ((text-widget (make-instance 'text :width 15 :height 2))
         (b1 (make-instance 'button
                            :text "Print"
                            :command #'(lambda () (princ (text text-widget)))))
         (b2 (make-instance 'button :text "Reset"
                            :command #'(lambda () (setf (text text-widget) "reset")))))
    (pack text-widget)
    (pack b1)
    (pack b2)))

      

+3


source







All Articles