:right-sidebar: True Scrollable =================================================================== .. currentmodule:: gi.repository.Gtk .. class:: Scrollable(*args, **kwargs) :no-contents-entry: Implementations: :class:`~gi.repository.Gtk.ColumnView`, :class:`~gi.repository.Gtk.GridView`, :class:`~gi.repository.Gtk.IconView`, :class:`~gi.repository.Gtk.ListBase`, :class:`~gi.repository.Gtk.ListView`, :class:`~gi.repository.Gtk.TextView`, :class:`~gi.repository.Gtk.TreeView`, :class:`~gi.repository.Gtk.Viewport` ``GtkScrollable`` is an interface for widgets with native scrolling ability. To implement this interface you should override the :obj:`~gi.repository.Gtk.Scrollable.props.hadjustment` and :obj:`~gi.repository.Gtk.Scrollable.props.vadjustment` properties. Creating a scrollable widget -------------------------------------------------------------------------------- All scrollable widgets should do the following. - When a parent widget sets the scrollable child widget’s adjustments, the widget should connect to the :obj:`~gi.repository.Gtk.Adjustment.signals.value_changed` signal. The child widget should then populate the adjustments’ properties as soon as possible, which usually means queueing an allocation right away and populating the properties in the :obj:`~gi.repository.Gtk.Widget.size_allocate` implementation. - Because its preferred size is the size for a fully expanded widget, the scrollable widget must be able to cope with underallocations. This means that it must accept any value passed to its :obj:`~gi.repository.Gtk.Widget.size_allocate` implementation. - When the parent allocates space to the scrollable child widget, the widget must ensure the adjustments’ property values are correct and up to date, for example using :obj:`~gi.repository.Gtk.Adjustment.configure`\. - When any of the adjustments emits the :obj:`~gi.repository.Gtk.Adjustment.signals.value_changed` signal, the scrollable widget should scroll its contents. Methods ------- .. rst-class:: interim-class .. class:: Scrollable :no-index: .. method:: get_border() -> ~typing.Tuple[bool, ~gi.repository.Gtk.Border] Returns the size of a non-scrolling border around the outside of the scrollable. An example for this would be treeview headers. GTK can use this information to display overlaid graphics, like the overshoot indication, at the right position. .. method:: get_hadjustment() -> ~gi.repository.Gtk.Adjustment | None Retrieves the ``GtkAdjustment`` used for horizontal scrolling. .. method:: get_hscroll_policy() -> ~gi.repository.Gtk.ScrollablePolicy Gets the horizontal ``GtkScrollablePolicy``\. .. method:: get_vadjustment() -> ~gi.repository.Gtk.Adjustment | None Retrieves the ``GtkAdjustment`` used for vertical scrolling. .. method:: get_vscroll_policy() -> ~gi.repository.Gtk.ScrollablePolicy Gets the vertical ``GtkScrollablePolicy``\. .. method:: set_hadjustment(hadjustment: ~gi.repository.Gtk.Adjustment | None = None) -> None Sets the horizontal adjustment of the ``GtkScrollable``\. :param hadjustment: a ``GtkAdjustment`` .. method:: set_hscroll_policy(policy: ~gi.repository.Gtk.ScrollablePolicy) -> None Sets the ``GtkScrollablePolicy``\. The policy determines whether horizontal scrolling should start below the minimum width or below the natural width. :param policy: the horizontal ``GtkScrollablePolicy`` .. method:: set_vadjustment(vadjustment: ~gi.repository.Gtk.Adjustment | None = None) -> None Sets the vertical adjustment of the ``GtkScrollable``\. :param vadjustment: a ``GtkAdjustment`` .. method:: set_vscroll_policy(policy: ~gi.repository.Gtk.ScrollablePolicy) -> None Sets the ``GtkScrollablePolicy``\. The policy determines whether vertical scrolling should start below the minimum height or below the natural height. :param policy: the vertical ``GtkScrollablePolicy`` Properties ---------- .. rst-class:: interim-class .. class:: Scrollable :no-index: .. attribute:: props.hadjustment :type: ~gi.repository.Gtk.Adjustment The type of the None singleton. .. attribute:: props.hscroll_policy :type: ~gi.repository.Gtk.ScrollablePolicy The type of the None singleton. .. attribute:: props.vadjustment :type: ~gi.repository.Gtk.Adjustment The type of the None singleton. .. attribute:: props.vscroll_policy :type: ~gi.repository.Gtk.ScrollablePolicy The type of the None singleton. Virtual Methods --------------- .. rst-class:: interim-class .. class:: Scrollable :no-index: .. method:: do_get_border() -> ~typing.Tuple[bool, ~gi.repository.Gtk.Border] Returns the size of a non-scrolling border around the outside of the scrollable. An example for this would be treeview headers. GTK can use this information to display overlaid graphics, like the overshoot indication, at the right position.