gtk.combo_box_text
Module for [ComboBoxText] class
Types 3
A GtkComboBoxText is a simple variant of #GtkComboBox that hides the model-view complexity for simple text-only use cases.
To create a GtkComboBoxText, use [gtk.combo_box_text.ComboBoxText.new_] or [gtk.combo_box_text.ComboBoxText.newWithEntry].
You can add items to a GtkComboBoxText with [gtk.combo_box_text.ComboBoxText.appendText], [gtk.combo_box_text.ComboBoxText.insertText] or [gtk.combo_box_text.ComboBoxText.prependText] and remove options with [gtk.combo_box_text.ComboBoxText.remove].
If the GtkComboBoxText contains an entry (via the “has-entry” property), its contents can be retrieved using [gtk.combo_box_text.ComboBoxText.getActiveText]. The entry itself can be accessed by calling [gtk.bin.Bin.getChild] on the combo box.
You should not call [gtk.combo_box.ComboBox.setModel] or attempt to pack more cells into this combo box via its GtkCellLayout interface.
GtkComboBoxText as GtkBuildable
The GtkComboBoxText implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element can specify the “id” corresponding to the appended text and also supports the regular translation attributes “translatable”, “context” and “comments”.
Here is a UI definition fragment specifying GtkComboBoxText items:
<object class="GtkComboBoxText">
<items>
<item translatable="yes" id="factory">Factory</item>
<item translatable="yes" id="home">Home</item>
<item translatable="yes" id="subway">Subway</item>
</items>
</object>CSS nodes
combobox
╰── box.linked
├── entry.combo
├── button.combo
╰── window.popupGtkComboBoxText has a single CSS node with name combobox. It adds the style class .combo to the main CSS nodes of its entry and button children, and the .linked class to the node of its internal box.
ComboBoxText self()Returns `this`, for use in `with` statements.ComboBoxTextGidBuilder builder()Get builder for [gtk.comboboxtext.ComboBoxText] Returns: New builder objectgtk.combo_box_text.ComboBoxText newWithEntry()Creates a new #GtkComboBoxText, which is a #GtkComboBox just displaying strings. The combo box created by this function has an entry. Returns: a new #GtkComboBoxTextvoid append(string id, string text)Appends text to the list of strings stored in combo_box. If id is non-null then it is used as the ID of the row.void appendText(string text)Appends text to the list of strings stored in combo_box.string getActiveText()Returns the currently active string in combobox, or null if none is selected. If combobox contains an entry, this function will return its contents (which will not necessarily be an item from the l...void insert(int position, string id, string text)Inserts text at position in the list of strings stored in combo_box. If id is non-null then it is used as the ID of the row. See #GtkComboBox:id-column.void insertText(int position, string text)Inserts text at position in the list of strings stored in combo_box.void prepend(string id, string text)Prepends text to the list of strings stored in combo_box. If id is non-null then it is used as the ID of the row.void prependText(string text)Prepends text to the list of strings stored in combo_box.void remove(int position)Removes the string at position from combo_box.void removeAll()Removes all the text entries from the combo box.Fluent builder for [gtk.combo_box_text.ComboBoxText]