How to make a Gtk.ComboBoxText's entry editable in Glade

I'm using Glade to write a PyGI app, and I've come across a problem whereby I've got a Gtk.ComboBoxText with a Gtk.Entry, but I cannot make the entry editable for some reason. I.e. when the UI is loaded, there is no way to input text in it.

I've looked at all the entry's properties and also those of the comboboxtext parent, but I could not find anything obvious that I'm missing. Oddly enough, if I create it with code only (i.e. with no Glade .ui files), that seems to work and the entry is then editable.

This code does not work

Code:

#!/usr/bin/env python
from gi.repository import Gtk
class Combo: def __init__(self): builder = Gtk.Builder() builder.add_from_file('combo.ui') window = builder.get_object('window1') window.connect('destroy', lambda w: Gtk.main_quit()) window.show_all()
Combo()
Gtk.main()

Glade file:

<?xml version="1.0" encoding="UTF-8"?>
<interface> <!-- interface-requires gtk+ 3.0 --> <object> <property name="can_focus">False</property> <child> <object> <property name="visible">True</property> <property name="can_focus">False</property> <property name="has_entry">True</property> <property name="entry_text_column">0</property> <property name="id_column">1</property> <child internal-child="entry"> <object> <property name="can_focus">False</property> </object> </child> </object> </child> </object>
</interface>

This code works

#!/usr/bin/env python
from gi.repository import Gtk
class Combo: def __init__(self): window = Gtk.Window() window.set_default_size(200, 200) combo = Gtk.ComboBoxText.new_with_entry() combo.set_hexpand(True) window.connect("destroy", lambda w: Gtk.main_quit()) window.add(combo) window.show_all()
Combo()
Gtk.main()

Any pointers on how to make the text entry editable in the Glade code?

1 Answer

Try setting can_focus to True, if you can't give keyboard focus to the entry you won't be able to type anything into it.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like