Re: Making Glade created ComboBox behave like Gtk2::ComboBox->new_text?



Daniel Kasak wrote:

You mean the 'ComboBox' from Gtk-2.2? If so, that's been depreciated for
quite a while. What version of Gtk to do have? If you've got Gtk-2.4 or
higher, you should use a 'ComboBoxEntry'. It allows you to use a
Gtk2::ListStore ( as you're trying to do above ) to store values for
your combo box. I think that's what your problem here is - you're trying
to use an old ComboBox as a ComboBoxEntry.

In my understanding, ComboBoxEntry is just a specialization of ComboBox,
ie a CombBox plus user entry. OptionMenu is deprecated, but ComboBox?

Meanwhile, I found out that I have to add the following code (cbox is
the widget from Glade):

    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);

Is this the canonical way? The code was shamelessly copied from
examples/combo_box.pl

Then I can use

    for ... {
        $cbox->append_text($label);
    }

Martin



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