Question

I know how to set the default selection in a ComboBox, but I have a ComboBoxText widget that allows the user to enter his/her gender. So, I could use Gtk.ComboBox.set_active(), but that would express some sort of sexism, as the default selection would be either "Male" or "Female".

My question is how can I set a placeholder string on my ComboBox, but without it being in the list of choices?

Using python3 with gobject introspection.

Was it helpful?

Solution

You could create the GtkComboBoxText with an entry, and then connect to the format-entry-text signal, and then return the default string if no other selection has been made. The Gtk+ docs contain an example of this signal (in C) here: http://developer.gnome.org/gtk3/3.4/GtkComboBox.html#GtkComboBox-format-entry-text.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top