in reply to cannot append items in combobox using Gtk2 and glade

Found the answer on a 6 year old mailing list thread, here's the code, but now working. The same glade file

#!/usr/bin/perl use strict; use warnings; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; use Gtk2::SimpleList; # Connect to the glade file my $builder = Gtk2::Builder->new (); $builder->add_from_file ('example.glade'); $builder->connect_signals (); # connect to the combobox my $cbox = $builder->get_object ('combobox1'); my @listing = qw/random stuff just to test /; my $text; my $model = new Gtk2::ListStore('Glib::String'); $cbox->clear(); my $renderer = new Gtk2::CellRendererText; $cbox->pack_start($renderer, FALSE); $cbox->set_attributes($renderer, text => 0); $cbox->set_model($model); # This is supposed to append the @listing to the # combobox foreach $text (@listing) { $cbox->append_text ($text) } $builder->get_object ('window1')->show_all; Gtk2->main;

Replies are listed 'Best First'.
Re^2: cannot append items in combobox using Gtk2 and glade
by Anonymous Monk on Mar 13, 2010 at 03:53 UTC
    Thx a lot! Who'd have thought it would be *this* complicated >.<