How do I get Ltk to display what the user is writing and what the functions print?
Asked Answered
N

1

1

The kind of functions are of the sort of:

(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've read the Ltk documentation, but there doesn't seem to be any examples of text widget usage.

Natishanative answered 10/11, 2008 at 10:0 Comment(0)
O
3

You create the text widget like every other widget. The Lisp-side object has text accessor function with writer method which sets the text on 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)))
Oldenburg answered 10/11, 2008 at 20:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.