LTK,按钮动作
我的第一个 LTK 应用程序。尝试使用输入字段中的参数执行函数。
(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))
为什么函数在源启动时只执行一次?然后-任何行动。
My first LTK-application. Trying to execute function with argument from 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))
Why function execute just once, when source is launched? And then - any actions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想传递回调,请使用
(lambda () ...)
,即在您的代码中:否则,您的
(test (text e))
将在在初始化对象之前调用make-instance
的时间。如果您打开调试输出,则更容易发现此问题:
(setf ltk:*debug-tk* t)
If you want to pass a callback, use
(lambda () ...)
, i.e. in your code:Otherwise, your
(test (text e))
is executed at the time ofmake-instance
call, before the object is initialized.It's easier to spot this problems, if you turn on debug output:
(setf ltk:*debug-tk* t)