gtk.combo_box
Module for [ComboBox] class
Types 3
A [gtk.combo_box.ComboBox] is a widget that allows the user to choose from a list of valid choices.
The [gtk.combo_box.ComboBox] displays the selected choice; when activated, the [gtk.combo_box.ComboBox] displays a popup which allows the user to make a new choice.
The [gtk.combo_box.ComboBox] uses the model-view pattern; the list of valid choices is specified in the form of a tree model, and the display of the choices can be adapted to the data in the model by using cell renderers, as you would in a tree view. This is possible since [gtk.combo_box.ComboBox] implements the [gtk.cell_layout.CellLayout] interface. The tree model holding the valid choices is not restricted to a flat list, it can be a real tree, and the popup will reflect the tree structure.
To allow the user to enter values not in the model, the property@Gtk.ComboBox:has-entry property allows the [gtk.combo_box.ComboBox] to contain a [gtk.entry.Entry]. This entry can be accessed by calling [gtk.combo_box.ComboBox.getChild] on the combo box.
For a simple list of textual choices, the model-view API of [gtk.combo_box.ComboBox] can be a bit overwhelming. In this case, [gtk.combo_box_text.ComboBoxText] offers a simple alternative. Both [gtk.combo_box.ComboBox] and [gtk.combo_box_text.ComboBoxText] can contain an entry.
CSS nodes
combobox
├── box.linked
│ ╰── button.combo
│ ╰── box
│ ├── cellview
│ ╰── arrow
╰── window.popupA normal combobox contains a box with the .linked class, a button with the .combo class and inside those buttons, there are a cellview and an arrow.
combobox
├── box.linked
│ ├── entry.combo
│ ╰── button.combo
│ ╰── box
│ ╰── arrow
╰── window.popupA [gtk.combo_box.ComboBox] with an entry has a single CSS node with name combobox. It contains a box with the .linked class. That box contains an entry and a button, both with the .combo class added. The button also contains another node with name arrow.
Accessibility
[gtk.combo_box.ComboBox] uses the [gtk.types.AccessibleRole.ComboBox] role.
Deprecated
ComboBox self()Returns `this`, for use in `with` statements.ComboBoxGidBuilder builder()Get builder for [gtk.combo_box.ComboBox] Returns: New builder objectvoid active(int propval) @propertySet `active` property. Params: propval = The item which is currently active.string activeId() @propertyGet `activeId` property. Returns: The value of the ID column of the active row.void activeId(string propval) @propertySet `activeId` property. Params: propval = The value of the ID column of the active row.gtk.types.SensitivityType buttonSensitivity() @propertyGet `buttonSensitivity` property. Returns: Whether the dropdown button is sensitive when the model is empty.void buttonSensitivity(gtk.types.SensitivityType propval) @propertySet `buttonSensitivity` property. Params: propval = Whether the dropdown button is sensitive when the model is empty.void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.int entryTextColumn() @propertyGet `entryTextColumn` property. Returns: The model column to associate with strings from the entry.void entryTextColumn(int propval) @propertySet `entryTextColumn` property. Params: propval = The model column to associate with strings from the entry.bool hasFrame() @propertyGet `hasFrame` property. Returns: The `has-frame` property controls whether a frame is drawn around the entry.void hasFrame(bool propval) @propertySet `hasFrame` property. Params: propval = The `has-frame` property controls whether a frame is drawn around the entry.int idColumn() @propertyGet `idColumn` property. Returns: The model column that provides string IDs for the values in the model, if != -1.void idColumn(int propval) @propertySet `idColumn` property. Params: propval = The model column that provides string IDs for the values in the model, if != -1.gtk.tree_model.TreeModel model() @propertyGet `model` property. Returns: The model from which the combo box takes its values.void model(gtk.tree_model.TreeModel propval) @propertySet `model` property. Params: propval = The model from which the combo box takes its values.bool popupFixedWidth() @propertyGet `popupFixedWidth` property. Returns: Whether the popup's width should be a fixed width matching the allocated width of the combo box.void popupFixedWidth(bool propval) @propertySet `popupFixedWidth` property. Params: propval = Whether the popup's width should be a fixed width matching the allocated width of the combo box.bool popupShown() @propertyGet `popupShown` property. Returns: Whether the combo boxes dropdown is popped up.gtk.combo_box.ComboBox newWithEntry()Creates a new empty [gtk.combo_box.ComboBox] with an entry.gtk.combo_box.ComboBox newWithModel(gtk.tree_model.TreeModel model)Creates a new [gtk.combo_box.ComboBox] with a model.gtk.combo_box.ComboBox newWithModelAndEntry(gtk.tree_model.TreeModel model)Creates a new empty [gtk.combo_box.ComboBox] with an entry and a model.int getActive()Returns the index of the currently active item.string getActiveId()Returns the ID of the active row of combo_box.bool getActiveIter(out gtk.tree_iter.TreeIter iter)Sets iter to point to the currently active item.gtk.types.SensitivityType getButtonSensitivity()Returns whether the combo box sets the dropdown button sensitive or not when there are no items in the model. Returns: [gtk.types.SensitivityType.On] if the dropdown button is sensitive when the mo...gtk.widget.Widget getChild()Gets the child widget of combobox. Returns: the child widget of comboboxint getEntryTextColumn()Returns the column which combobox is using to get the strings from to display in the internal entry. Returns: A column in the data source model of combobox.bool getHasEntry()Returns whether the combo box has an entry. Returns: whether there is an entry in combo_box.int getIdColumn()Returns the column which combobox is using to get string IDs for values from. Returns: A column in the data source model of combobox.gtk.tree_model.TreeModel getModel()Returns the [gtk.treemodel.TreeModel] of combobox. Returns: A [gtk.tree_model.TreeModel] which was passed during construction.bool getPopupFixedWidth()Gets whether the popup uses a fixed width. Returns: true if the popup uses a fixed widthvoid popdown()Hides the menu or dropdown list of combo_box.void popup()Pops up the menu or dropdown list of combo_box.void popupForDevice(gdk.device.Device device)Pops up the menu of combo_box.void setActive(int index)Sets the active item of combo_box to be the item at index.bool setActiveId(string activeId = null)Changes the active row of combobox to the one that has an ID equal to activeid.void setActiveIter(gtk.tree_iter.TreeIter iter = null)Sets the current active item to be the one referenced by iter.void setButtonSensitivity(gtk.types.SensitivityType sensitivity)Sets whether the dropdown button of the combo box should update its sensitivity depending on the model contents.void setChild(gtk.widget.Widget child = null)Sets the child widget of combo_box.void setEntryTextColumn(int textColumn)Sets the model column which combobox should use to get strings from to be textcolumn.void setIdColumn(int idColumn)Sets the model column which combo_box should use to get string IDs for values from.void setModel(gtk.tree_model.TreeModel model = null)Sets the model used by combo_box to be model.void setPopupFixedWidth(bool fixed)Specifies whether the popup’s width should be a fixed width.void setRowSeparatorFunc(gtk.types.TreeViewRowSeparatorFunc func = null)Sets the row separator function, which is used to determine whether a row should be drawn as a separator.gulong connectActivate(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 2)Connect to `Activate` signal.gulong connectChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 2)Connect to `Changed` signal.gulong connectFormatEntryText(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == string)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == string)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 3)Connect to `FormatEntryText` signal.gulong connectMoveActive(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.ScrollType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 3)Connect to `MoveActive` signal.gulong connectPopdown(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 2)Connect to `Popdown` signal.gulong connectPopup(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.combo_box.ComboBox)))
&& Parameters!T.length < 2)Connect to `Popup` signal.T active(int propval)Set `active` property. Params: propval = The item which is currently active.T activeId(string propval)Set `activeId` property. Params: propval = The value of the ID column of the active row. Returns: Builder instance for fluent chainingT buttonSensitivity(gtk.types.SensitivityType propval)Set `buttonSensitivity` property. Params: propval = Whether the dropdown button is sensitive when the model is empty. Returns: Builder instance for fluent chainingT child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chainingT entryTextColumn(int propval)Set `entryTextColumn` property. Params: propval = The model column to associate with strings from the entry.T hasEntry(bool propval)Set `hasEntry` property. Params: propval = Whether the combo box has an entry. Returns: Builder instance for fluent chainingT hasFrame(bool propval)Set `hasFrame` property. Params: propval = The `has-frame` property controls whether a frame is drawn around the entry. Returns: Builder instance for fluent chainingT idColumn(int propval)Set `idColumn` property. Params: propval = The model column that provides string IDs for the values in the model, if != -1. Returns: Builder instance for fluent chainingT model(gtk.tree_model.TreeModel propval)Set `model` property. Params: propval = The model from which the combo box takes its values. Returns: Builder instance for fluent chainingT popupFixedWidth(bool propval)Set `popupFixedWidth` property. Params: propval = Whether the popup's width should be a fixed width matching the allocated width of the combo box. Returns: Builder instance for fluent chainingFluent builder for [gtk.combo_box.ComboBox]
ComboBox build()