LTK: listbox

Discussion of Common Lisp
Post Reply
Posts: 19
Joined: Thu May 16, 2013 1:42 pm

LTK: listbox

Post by aidlt » Fri Jul 05, 2013 3:36 pm

LTK users here? :)

I've come across certain issues concerning the listbox widget.

First of all, evidently there's no `activate' method.

Suppose I create a listbox with three items and select the second (i. e. the middle) one at the initialization:

Code: Select all

(with-ltk ()
  (let ((l (make-instance 'listbox)))
    (listbox-append l '("foo" "bar" "baz"))
    (listbox-select l 1)
    (pack l)
    (focus l)))
Naturally when the user presses arrow keys, it's desirable that the selected item should be active. However, it's the last one that is active in the example above. As a way out one could use the activate method, but it hasn't apparently been implemented. Actually the implementation isn't hard at all:

Code: Select all

(defgeneric listbox-activate (l index))
(defmethod listbox-activate ((l listbox) index)
  (format-wish "~a activate ~a" (widget-path l) index) 
However, I'm afraid I may be missing some point...

On a related note: the listbox widget has the listvariable option. However, I failed to produce a working example. Any suggestions? (BTW, I greatly appreciate LTK's design in the way that it keeps all the StringVar mess under the hood, unlike Python. It would be nice to have the VALUE method for listboxes as well. Yet I don't know how to retrieve listbox items if not implementing listbox-get, which is also missing and perhaps obsolete.)

I've found the LTK mailing list, but something must be wrong with mailing lists on, the links are broken for the most part.

Posts: 166
Joined: Sun Nov 28, 2010 4:21 pm

Re: LTK: listbox

Post by pjstirling » Sat Jul 06, 2013 12:32 pm

I'm afraid I can't help you with LTK, but your problem with the mailing list is because is going through a very horrible transition, apparently the maintainer was forced to switch hosting provider at short notice and the mailing lists were a casualty because the new host doesn't support the same mail manager.

Posts: 19
Joined: Thu May 16, 2013 1:42 pm

Re: LTK: listbox

Post by aidlt » Sun Jul 07, 2013 1:58 am

Thanks, pjstirling, I didn't know that.

Posts: 19
Joined: Thu May 16, 2013 1:42 pm

Re: LTK: listbox

Post by aidlt » Mon Jul 08, 2013 4:13 pm

As for the listvariable, there's obviously no way to use it:

However, it's not hard to implement mutatis mutandis:

Code: Select all

(defclass tklistvariable ()) 

(defmethod initialize-instance :around ((v tklistvariable) &key)
  (format-wish "~a configure -listvariable ~a ; global ~a ; set ~a {}" (widget-path v) (name v) (name v) (name v)))

(defmethod value ((v tklistvariable))
  (format-wish "global ~a; senddatastrings $~a" (name v) (name v))

(defmethod (setf value) (val (v tklistvariable))
  (format-wish "global ~a; set ~a [list ~{ \{~a\}~}]" (name v) (name v) val)

(defwrapper listbox (widget tklistvariable)
  ((xscroll :accessor xscroll :initarg :xscroll :initform nil)
   (yscroll :accessor yscroll :initarg :yscroll :initform nil))
In the meanwhile I'm pondering why we need the option setter configure if we already have the getter cget and setf. Then there wouldn't be problems like this: ... /focus=502
setfing could be implemented in just few lines. :?

Post Reply