Use input combobox when migrating to pygobject, glade and gtk3

I have been developing in python with clearings and pigtails from 3 months, but even before I got used to it, it was already out of date.

Using Archlinux, my system is constantly being updated, so I am forced to use gtk3, even if I find that it has few missing features compared to gtk2.

So I decided to switch to pygobject. Unfortunately, the documentation is not complete.

I have successfully updated my glade file and my python code to the new system, but one error exists.

In one of my programs, I have a summary with a record. I use the get_active_text () method to get the contents of the entry, regardless of whether it was selected from the drop-down list or entered by the user.

This method no longer exists (I suppose because it gave me an error), so I use this instead:

def get_license(self):
    #return self.combobox_license.get_active_text()
    tree_iter = self.combobox_license.get_active_iter()
    if tree_iter != None:
        model = self.combobox_license.get_model()
        return model[tree_iter][0]
    else:
        entry = self.combobox_license.get_child()
        return entry.get_text()

As you can see, the old code is commented out.

This code works, but I have a strange problem: I can not use the record!

I can select the text from the drop-down list, but the record is not used. I can choose, but I can not enter it.

Is this the new behavior I need to activate? I have no problems with the gtk2 version of the program.

Here is the part in my glade file that describes the combobox entry:

  <object class="GtkComboBox" id="combobox_license">
    <property name="visible">True</property>
    <property name="can_focus">False</property>
    <property name="model">liststore_license</property>
    <property name="has_entry">True</property>
    <property name="entry_text_column">0</property>
    <signal name="changed" handler="on_combobox_license_changed" swapped="no"/>
    <child>
      <object class="GtkCellRendererText" id="cellrenderertext_license"/>
    </child>
    <child internal-child="entry">
      <object class="GtkEntry" id="combobox-entry2">
        <property name="can_focus">False</property>
        <property name="buffer">entrybuffer1</property>
      </object>
    </child>
  </object>

I created a liststore with one gchararray type column containing text. The cell is displayed using GtkCellRenderer (but the "text" property for cellrenderer is not defined, because if I define it to 0 (gchararray), I get the text twice !)

, entrybuffer , .

EDIT: : can_focus . , .

, , , .

+5
2

can_focus combobox true.

+4

get_active_text(), Gtk.ComboBoxText Gtk.ComboBox. API GTK 3.

+1

All Articles