in reply to How to printout a Gtk2::ComboBox

my @model=$combo->get_model; foreach(@model) { print $_[0]; }
This is what i have tried in perl

2019-08-27 Athanasius fixed code tags.

Replies are listed 'Best First'.
Re^2: How to printout a Gtk2::ComboBox
by hippo (Archbishop) on Aug 16, 2019 at 19:24 UTC

    Thanks for this code. (you're just missing a </code> terminating tag, but that's of little consequence in this short example).

    I know almost zero about Gtk2 (and I can't find Gtk2::Combobox - do you mean Gtk2::Ex::ComboBox?) but I can say that $_[0] is likely to be undefined here. foreach just sets $_, not @_. Maybe try printing that, or using Data::Dumper or similar to dump the object, if it is one? Just a thought.

    An SSCCE is always best.

      I have tried it both ways with $_ and $_[0]

Re^2: How to printout a Gtk2::ComboBox
by Anonymous Monk on Aug 16, 2019 at 23:02 UTC
    The docs for Gtk2::Ex::ComboBox say you want get_treeview to get the model:
    my @model = $combo->get_treeview; print $_ for @model;
    "Returns the treeview that serves as the model for the ComboBox".