:right-sidebar: True DropDown =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: DropDown(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.Gtk.Widget`, :class:`~gi.repository.GObject.InitiallyUnowned`, :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Gtk.Accessible`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget` :Constructors: :: DropDown(**properties) new(model:Gio.ListModel=None, expression:Gtk.Expression=None) -> Gtk.Widget new_from_strings(strings:list) -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: DropDown :no-index: .. classmethod:: new(model: ~gi.repository.Gio.ListModel | None = None, expression: ~gi.repository.Gtk.Expression | None = None) -> ~gi.repository.Gtk.Widget Creates a new ``GtkDropDown``. You may want to call :obj:`~gi.repository.Gtk.DropDown.set_factory` to set up a way to map its items to widgets. :param model: the model to use :param expression: the expression to use .. classmethod:: new_from_strings(strings: ~typing.Sequence[str]) -> ~gi.repository.Gtk.Widget Creates a new ``GtkDropDown`` that is populated with the strings. :param strings: The strings to put in the dropdown Methods ------- .. rst-class:: interim-class .. class:: DropDown :no-index: .. method:: get_enable_search() -> bool Returns whether search is enabled. .. method:: get_expression() -> ~gi.repository.Gtk.Expression | None Gets the expression set that is used to obtain strings from items. See :obj:`~gi.repository.Gtk.DropDown.set_expression`. .. method:: get_factory() -> ~gi.repository.Gtk.ListItemFactory | None Gets the factory that's currently used to populate list items. The factory returned by this function is always used for the item in the button. It is also used for items in the popup if :obj:`~gi.repository.Gtk.DropDown.props.list_factory` is not set. .. method:: get_header_factory() -> ~gi.repository.Gtk.ListItemFactory | None Gets the factory that's currently used to create header widgets for the popup. .. versionadded:: 4.12 .. method:: get_list_factory() -> ~gi.repository.Gtk.ListItemFactory | None Gets the factory that's currently used to populate list items in the popup. .. method:: get_model() -> ~gi.repository.Gio.ListModel | None Gets the model that provides the displayed items. .. method:: get_search_match_mode() -> ~gi.repository.Gtk.StringFilterMatchMode Returns the match mode that the search filter is using. .. versionadded:: 4.12 .. method:: get_selected() -> int Gets the position of the selected item. .. method:: get_selected_item() -> ~gi.repository.GObject.Object | None Gets the selected item. If no item is selected, :const:`None` is returned. .. method:: get_show_arrow() -> bool Returns whether to show an arrow within the widget. .. versionadded:: 4.6 .. method:: set_enable_search(enable_search: bool) -> None Sets whether a search entry will be shown in the popup that allows to search for items in the list. Note that :obj:`~gi.repository.Gtk.DropDown.props.expression` must be set for search to work. :param enable_search: whether to enable search .. method:: set_expression(expression: ~gi.repository.Gtk.Expression | None = None) -> None Sets the expression that gets evaluated to obtain strings from items. This is used for search in the popup. The expression must have a value type of :obj:`str`. :param expression: a ``GtkExpression`` .. method:: set_factory(factory: ~gi.repository.Gtk.ListItemFactory | None = None) -> None Sets the ``GtkListItemFactory`` to use for populating list items. :param factory: the factory to use .. method:: set_header_factory(factory: ~gi.repository.Gtk.ListItemFactory | None = None) -> None Sets the ``GtkListItemFactory`` to use for creating header widgets for the popup. .. versionadded:: 4.12 :param factory: the factory to use .. method:: set_list_factory(factory: ~gi.repository.Gtk.ListItemFactory | None = None) -> None Sets the ``GtkListItemFactory`` to use for populating list items in the popup. :param factory: the factory to use .. method:: set_model(model: ~gi.repository.Gio.ListModel | None = None) -> None Sets the ``GListModel`` to use. :param model: the model to use .. method:: set_search_match_mode(search_match_mode: ~gi.repository.Gtk.StringFilterMatchMode) -> None Sets the match mode for the search filter. .. versionadded:: 4.12 :param search_match_mode: the new match mode .. method:: set_selected(position: int) -> None Selects the item at the given position. :param position: the position of the item to select, or :const:`~gi.repository.Gtk.INVALID_LIST_POSITION` .. method:: set_show_arrow(show_arrow: bool) -> None Sets whether an arrow will be displayed within the widget. .. versionadded:: 4.6 :param show_arrow: whether to show an arrow within the widget Properties ---------- .. rst-class:: interim-class .. class:: DropDown :no-index: .. attribute:: props.enable_search :type: bool Whether to show a search entry in the popup. Note that search requires :obj:`~gi.repository.Gtk.DropDown.props.expression` to be set. .. attribute:: props.expression :type: ~gi.repository.Gtk.Expression An expression to evaluate to obtain strings to match against the search term. See :obj:`~gi.repository.Gtk.DropDown.props.enable_search` for how to enable search. If :obj:`~gi.repository.Gtk.DropDown.props.factory` is not set, the expression is also used to bind strings to labels produced by a default factory. .. attribute:: props.factory :type: ~gi.repository.Gtk.ListItemFactory Factory for populating list items. .. attribute:: props.header_factory :type: ~gi.repository.Gtk.ListItemFactory The factory for creating header widgets for the popup. .. versionadded:: 4.12 .. attribute:: props.list_factory :type: ~gi.repository.Gtk.ListItemFactory The factory for populating list items in the popup. If this is not set, :obj:`~gi.repository.Gtk.DropDown.props.factory` is used. .. attribute:: props.model :type: ~gi.repository.Gio.ListModel Model for the displayed items. .. attribute:: props.search_match_mode :type: ~gi.repository.Gtk.StringFilterMatchMode The match mode for the search filter. .. versionadded:: 4.12 .. attribute:: props.selected :type: int The position of the selected item. If no item is selected, the property has the value :const:`~gi.repository.Gtk.INVALID_LIST_POSITION`. .. attribute:: props.selected_item :type: ~gi.repository.GObject.Object The selected item. .. attribute:: props.show_arrow :type: bool Whether to show an arrow within the GtkDropDown widget. .. versionadded:: 4.6 Signals ------- .. rst-class:: interim-class .. class:: DropDown.signals :no-index: .. method:: activate() -> None Emitted to when the drop down is activated. The ``::activate`` signal on ``GtkDropDown`` is an action signal and emitting it causes the drop down to pop up its dropdown. .. versionadded:: 4.6