:right-sidebar: True SearchBar =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: SearchBar(**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: :: SearchBar(**properties) new() -> Gtk.Widget Constructors ------------ .. rst-class:: interim-class .. class:: SearchBar :no-index: .. classmethod:: new() -> ~gi.repository.Gtk.Widget Creates a ``GtkSearchBar``. You will need to tell it about which widget is going to be your text entry using :obj:`~gi.repository.Gtk.SearchBar.connect_entry`. Methods ------- .. rst-class:: interim-class .. class:: SearchBar :no-index: .. method:: connect_entry(entry: ~gi.repository.Gtk.Editable) -> None Connects the ``GtkEditable`` widget passed as the one to be used in this search bar. The entry should be a descendant of the search bar. Calling this function manually is only required if the entry isn’t the direct child of the search bar (as in our main example). :param entry: a ``GtkEditable`` .. method:: get_child() -> ~gi.repository.Gtk.Widget | None Gets the child widget of ``bar``. .. method:: get_key_capture_widget() -> ~gi.repository.Gtk.Widget | None Gets the widget that ``bar`` is capturing key events from. .. method:: get_search_mode() -> bool Returns whether the search mode is on or off. .. method:: get_show_close_button() -> bool Returns whether the close button is shown. .. method:: set_child(child: ~gi.repository.Gtk.Widget | None = None) -> None Sets the child widget of ``bar``. :param child: the child widget .. method:: set_key_capture_widget(widget: ~gi.repository.Gtk.Widget | None = None) -> None Sets ``widget`` as the widget that ``bar`` will capture key events from. If key events are handled by the search bar, the bar will be shown, and the entry populated with the entered text. Note that despite the name of this function, the events are only 'captured' in the bubble phase, which means that editable child widgets of ``widget`` will receive text input before it gets captured. If that is not desired, you can capture and forward the events yourself with :obj:`~gi.repository.Gtk.EventControllerKey.forward`. :param widget: a ``GtkWidget`` .. method:: set_search_mode(search_mode: bool) -> None Switches the search mode on or off. :param search_mode: the new state of the search mode .. method:: set_show_close_button(visible: bool) -> None Shows or hides the close button. Applications that already have a “search” toggle button should not show a close button in their search bar, as it duplicates the role of the toggle button. :param visible: whether the close button will be shown or not Properties ---------- .. rst-class:: interim-class .. class:: SearchBar :no-index: .. attribute:: props.child :type: ~gi.repository.Gtk.Widget The child widget. .. attribute:: props.key_capture_widget :type: ~gi.repository.Gtk.Widget The key capture widget. .. attribute:: props.search_mode_enabled :type: bool Whether the search mode is on and the search bar shown. .. attribute:: props.show_close_button :type: bool Whether to show the close button in the search bar.