guile-gtk-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to get value from combo


From: Maarten Grachten
Subject: Re: how to get value from combo
Date: Wed, 1 Dec 2004 14:02:48 +0100 (CET)

On Wed, 1 Dec 2004, Andreas Rottmann wrote:

> > the code you provided prints all the values in the combo. But how do I
> > know which is the currently selected item?
> >
> Have you tried (get-active-iter combo)?

Ok! You helped me. The get-active-iter needed an iter object as argument
as well, not just the combo. But upon looking up the get-active-iter in
the documentation, I found the get-active method, which just returns the
index of the list of items. So I can get the current (active) element very
easily now, without reference to the whole model/iter stuff at all (which
is what I preferred):

(use-modules (gnome gtk))

(let ((combo (gtk-combo-box-entry-new-text))
      (items '("foo" "bar" "baz")))
  (for-each (lambda (text)
              (append-text combo text))
            items)
  (write-line (if (< (get-active combo) 0)
                  #f
                 (list-ref items (get-active combo)))))

Perhaps I didn't state clearly I wanted just a simple silly thing like
this. But thanks a lot for helping me!

Maarten





reply via email to

[Prev in Thread] Current Thread [Next in Thread]