1

函数类型如下:

(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")))

我已阅读 Ltk 文档,但似乎没有任何文本小部件使​​用示例。

4

1 回答 1

3

您像其他所有小部件一样创建文本小部件。Lisp 端对象具有text带有 writer 方法的访问器函数,该方法在 Tk 端设置文本。最小的例子:

(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)))
于 2008-11-10T20:19:43.957 回答