访问 ltk 小部件选项的值

发布于 2024-10-31 16:48:08 字数 270 浏览 1 评论 0原文

我正在尝试使用 ltk 在 common lisp 中制作一个 GUI 应用程序,但有一件事我无法弄清楚。我知道我可以使用 configure 设置 ltk 小部件的选项,但我无法找到读取值的方法。

例如,我创建了一个画布实例,

(make-instance 'canvas :width 400 :height 400)

然后我想编写一个在某些计算中使用宽度和高度的方法。我如何访问这些?

I am trying to make a GUI application in common lisp with ltk, and there is one thing I just cannot figure out. I know I can set options of ltk widgets with configure, but I cannot figure out a way to read the values.

For example, I create an instance of a canvas with

(make-instance 'canvas :width 400 :height 400)

Then I want to write a method that will use the width and height in some calculations. How do I access these?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

未蓝澄海的烟 2024-11-07 16:48:08

我在 ltk 用户列表中问过同样的问题并得到了答案。

简而言之,cget 函数是 configure 的对应函数,

因此,设置画布宽度(配置 canvas :witdh 值)并检索它(cget canvas :width)。

问候,

安德烈

I've asked this same question in the ltk user list and got an answer.

In short, the cget function is the counterpart of configure

So, to set the canvas width you do (configure canvas :witdh value) and to retrieve it you do (cget canvas :width).

Regards,

André

末骤雨初歇 2024-11-07 16:48:08
(require :ltk)
(in-package :ltk-user)
(defparameter *can*
 (make-instance 'canvas :width 400 :height 400))

实际上,宽度和高度存储在字符串中。
不知道以后能不能调整一下。也许可以在 ltk 邮件列表上询问。

#<CANVAS {1005A00C21}>
--------------------
Class: #<STANDARD-CLASS CANVAS>
--------------------
 Group slots by inheritance [ ]
 Sort slots alphabetically  [X]

All Slots:
[ ]  INIT-COMMAND      = "canvas ~A  -height 400 -width 400"
[ ]  MASTER            = NIL
[ ]  NAME              = "wc"
[ ]  SCROLLREGION-X0   = NIL
[ ]  SCROLLREGION-X1   = NIL
[ ]  SCROLLREGION-Y0   = NIL
[ ]  SCROLLREGION-Y1   = NIL
[ ]  WIDGET-CLASS-NAME = "canvas"
[ ]  WIDGET-PATH       = NIL
[ ]  XSCROLL           = NIL
[ ]  YSCROLL           = NIL

[set value]  [make unbound]
(require :ltk)
(in-package :ltk-user)
(defparameter *can*
 (make-instance 'canvas :width 400 :height 400))

Indeed the width and height are stored in the string.
I don't know if your can adjust this afterwards. Maybe ask on the ltk mailing list.

#<CANVAS {1005A00C21}>
--------------------
Class: #<STANDARD-CLASS CANVAS>
--------------------
 Group slots by inheritance [ ]
 Sort slots alphabetically  [X]

All Slots:
[ ]  INIT-COMMAND      = "canvas ~A  -height 400 -width 400"
[ ]  MASTER            = NIL
[ ]  NAME              = "wc"
[ ]  SCROLLREGION-X0   = NIL
[ ]  SCROLLREGION-X1   = NIL
[ ]  SCROLLREGION-Y0   = NIL
[ ]  SCROLLREGION-Y1   = NIL
[ ]  WIDGET-CLASS-NAME = "canvas"
[ ]  WIDGET-PATH       = NIL
[ ]  XSCROLL           = NIL
[ ]  YSCROLL           = NIL

[set value]  [make unbound]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文