:right-sidebar: True Scrollbar =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Scrollbar(**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.AccessibleRange`, :class:`~gi.repository.Gtk.Buildable`, :class:`~gi.repository.Gtk.ConstraintTarget`, :class:`~gi.repository.Gtk.Orientable` The ``GtkScrollbar`` widget is a horizontal or vertical scrollbar. .. image:: https://docs.gtk.org/gtk4/scrollbar.png Its position and movement are controlled by the adjustment that is passed to or created by :obj:`~gi.repository.Gtk.Scrollbar.new`\. See :obj:`~gi.repository.Gtk.Adjustment` for more details. The :obj:`~gi.repository.Gtk.Adjustment.props.value` field sets the position of the thumb and must be between :obj:`~gi.repository.Gtk.Adjustment.props.lower` and :obj:`~gi.repository.Gtk.Adjustment.props.upper` - :obj:`~gi.repository.Gtk.Adjustment.props.page_size`\. The :obj:`~gi.repository.Gtk.Adjustment.props.page_size` represents the size of the visible scrollable area. The fields :obj:`~gi.repository.Gtk.Adjustment.props.step_increment` and :obj:`~gi.repository.Gtk.Adjustment.props.page_increment` fields are added to or subtracted from the :obj:`~gi.repository.Gtk.Adjustment.props.value` when the user asks to move by a step (using e.g. the cursor arrow keys) or by a page (using e.g. the Page Down/Up keys). CSS nodes -------------------------------------------------------------------------------- .. code-block:: :dedent: scrollbar ╰── range[.fine-tune] ╰── trough ╰── slider ``GtkScrollbar`` has a main CSS node with name scrollbar and a subnode for its contents. The main node gets the .horizontal or .vertical style classes applied, depending on the scrollbar's orientation. The range node gets the style class .fine-tune added when the scrollbar is in 'fine-tuning' mode. Other style classes that may be added to scrollbars inside :obj:`~gi.repository.Gtk.ScrolledWindow` include the positional classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering). Accessibility -------------------------------------------------------------------------------- ``GtkScrollbar`` uses the :const:`~gi.repository.Gtk.AccessibleRole.SCROLLBAR` role. Constructors ------------ .. rst-class:: interim-class .. class:: Scrollbar :no-index: .. classmethod:: new(orientation: ~gi.repository.Gtk.Orientation, adjustment: ~gi.repository.Gtk.Adjustment | None = None) -> ~gi.repository.Gtk.Widget Creates a new scrollbar with the given orientation. :param orientation: the scrollbar’s orientation. :param adjustment: the :obj:`~gi.repository.Gtk.Adjustment` to use, or :const:`None` to create a new adjustment. Methods ------- .. rst-class:: interim-class .. class:: Scrollbar :no-index: .. method:: get_adjustment() -> ~gi.repository.Gtk.Adjustment Returns the scrollbar's adjustment. .. method:: set_adjustment(adjustment: ~gi.repository.Gtk.Adjustment | None = None) -> None Makes the scrollbar use the given adjustment. :param adjustment: the adjustment to set Properties ---------- .. rst-class:: interim-class .. class:: Scrollbar :no-index: .. attribute:: props.adjustment :type: ~gi.repository.Gtk.Adjustment The type of the None singleton.