in reply to How to printout a Gtk2::ComboBox

I suspect the python bindings have some overloading when used as an iterable.

In the perl bindings you get the treemodel object and then iterate over it using the iter_next or foreach methods.

See http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/TreeModel.html#_model_foreach_func_ and http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/TreeModel.html#treeiter_tree_model_4

Maybe something like this will work (untested).

my $callback = sub { my ($model, $path, $iter) = @_; my @selected = $model->get($iter); print @selected; # return false to ensure we keep iterating return; } my $model = $combo->get_model; $model->foreach ($callback);

Replies are listed 'Best First'.
Re^2: How to printout a Gtk2::ComboBox
by swl (Prior) on Aug 16, 2019 at 22:59 UTC

    And just for completeness, here is an example using iter_next. One could argue that the lack of callbacks make this somewhat easier to read than the foreach example.

    my $iter = $model->get_iter_first(); while ($iter) { my @selected = $labels_model->get( $iter ); print @selected; $iter = $model->iter_next( $iter ); }

    See also the more detailed foreach example by kikuchiyo in 11104587.