user629132
user629132

Reputation:

Acessing values of ltk widget options

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?

Upvotes: 3

Views: 383

Answers (2)

andrers52
andrers52

Reputation: 554

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é

Upvotes: 2

whoplisp
whoplisp

Reputation: 2518

(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]

Upvotes: 1

Related Questions