[pygtk] Inserting items into ComboBox

Johannes Bauer dfnsonfsduifb at gmx.de
Sat Mar 7 01:58:03 WST 2009


Walter Leibbrandt schrieb:

> And so I learn something new! On a hunch, I compared a Glade file with
> an empty (unaltered) combo box and a combo box with its "Items" field
> "changed". I put the "changed" in quotes, because what I did was add a
> character and delete it again, so no text was really added. It turns out
> that the output XML differs by one line that defines an "items" property
> (see attached comboboxes.diff).

Still, this should be used with caution - not all glade versions behave
like this appearently. I'm on a Ubuntu Intrepid Glade 3.4.5. Initially,
I have my empty combobox (excerpt form .glade file):

<widget class="GtkComboBox" id="Devices_Combobox">
    <property name="visible">True</property>
</widget>

Then I add an item and save:

<widget class="GtkComboBox" id="Devices_Combobox">
    <property name="visible">True</property>
    <property name="items" translatable="yes">foobar</property>
</widget>

and remove the property again and save:

<widget class="GtkComboBox" id="Devices_Combobox">
    <property name="visible">True</property>
</widget>

This, the "items" property completely disappered. However, when I
manually modify the glade file in the way you described by applying your
patch (well, manually):

<widget class="GtkComboBox" id="Devices_Combobox">
    <property name="visible">True</property>
    <property name="items" translatable="true"></property>
</widget>

and load that glade-File in my version of glade and save it again
immediately:

<widget class="GtkComboBox" id="Devices_Combobox">
	<property name="visible">True</property>
	<property name="items"></property>
</widget>

However, one must be careful with such a version of glade as mine not to
click on the "items" button and click OK, as the property "items" then
disappears again when the Glade file is saved.

It is unfortunate, in my opionion, that this behaviour obviously differs
between versions of Glade.

Kind regards,
Johannes


More information about the pygtk mailing list