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: Andreas Rottmann
Subject: Re: how to get value from combo
Date: Wed, 01 Dec 2004 13:22:16 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Maarten Grachten <address@hidden> writes:

> Hi,
>
> I just started with guile-gnome and made a combo box like this:
>
> (define combo (gtk-combo-box-entry-new-text))
> (for-each (lambda (i) (append-text combo i)) '("a" "b" "c"))
>
> but I don't know how to read out the current value. In the C/python docs
> it seems you can access an 'entry' attribute of the combo, but the
> get-entry method isn't defined for the combo. I struggled
> with the model associated to the combo but the furthest I got was:
>
> (connect combo 'changed
>   (lambda (b)
>     (get-value
>       (get-model b)
>       (get-iter-first (get-model b) 0))))
>
> which gives me "a" in all cases. Obviously because of the get-iter-first.
> I don't see how to do it. Can anybody please give me a little hint?
>
(use-modules (gnome gtk))

(let ((combo (gtk-combo-box-entry-new-text)))
  (for-each (lambda (text)
              (append-text combo text))
            '("foo" "bar" "baz"))
  
  (let ((model (get-model combo)))
    (let loop ((iter (get-iter-first model)))
      (if iter
          (begin
            (format #t "~A\n" (get-value model iter 0))
            (loop (iter-next model iter)))))))

HTH, Rotty  
-- 
Andreas Rottmann         | address@hidden      | address@hidden | address@hidden
http://yi.org/rotty      | GnuPG Key: http://yi.org/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

A. Because it breaks the logical sequence of discussion
Q. Why is top posting bad?




reply via email to

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