我的第一个LTK应用程序。正在尝试使用entry-field中的参数执行函数。
(defpackage :test
(:use :cl
:ltk))
(in-package :test)
(defun main()
(with-ltk ()
(let* ((f (make-instance 'frame
:height 200
:width 300))
(e (make-instance 'entry
:master f
))
(b (make-instance 'button
:master f
:text "Go"
:command (test (text e)))))
(wm-title *tk* "Test")
(pack f)
(pack e :side :left)
(pack b :side :left)
(configure f :borderwidth 3)
(configure f :relief :sunken))))
(defun test (str)
(format t "String: ~a" str))为什么源码启动时,函数只执行一次?然后-任何动作。
发布于 2011-10-31 17:57:13
如果你想传递一个回调,使用(lambda () ...),即在你的代码中:
...
(b (make-instance 'button
:master f
:text "Go"
:command (lambda () (test (text e))))))否则,您的(test (text e))将在make-instance调用时,即对象初始化之前执行。
如果启用debug output:(setf ltk:*debug-tk* t),则更容易发现此问题
https://stackoverflow.com/questions/7945620
复制相似问题