3

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?

2 Answers2

2

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é

andrers52
  • 524
  • 6
  • 9
  • Thank you! It seems to work. It seems to return the value as string. As far as I can tell, there is no mention of this in ltk documentation. –  Sep 08 '11 at 00:26
1
(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]
whoplisp
  • 2,508
  • 16
  • 19