gtk.scrolled_window
Module for [ScrolledWindow] class
Types 3
[gtk.scrolled_window.ScrolledWindow] is a container that makes its child scrollable.
It does so using either internally added scrollbars or externally associated adjustments, and optionally draws a frame around the child.
Widgets with native scrolling support, i.e. those whose classes implement the [gtk.scrollable.Scrollable] interface, are added directly. For other types of widget, the class [gtk.viewport.Viewport] acts as an adaptor, giving scrollability to other widgets. [gtk.scrolled_window.ScrolledWindow.setChild] intelligently accounts for whether or not the added child is a [gtk.scrollable.Scrollable]. If it isn’t, then it wraps the child in a [gtk.viewport.Viewport]. Therefore, you can just add any child widget and not worry about the details.
If [gtk.scrolled_window.ScrolledWindow.setChild] has added a [gtk.viewport.Viewport] for you, it will be automatically removed when you unset the child. Unless property@Gtk.ScrolledWindow:hscrollbar-policy and property@Gtk.ScrolledWindow:vscrollbar-policy are [gtk.types.PolicyType.Never] or [gtk.types.PolicyType.External], [gtk.scrolled_window.ScrolledWindow] adds internal [gtk.scrollbar.Scrollbar] widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the [gtk.scrolled_window.ScrolledWindow.hadjustment] and [gtk.scrolled_window.ScrolledWindow.vadjustment] that are associated with the [gtk.scrolled_window.ScrolledWindow]. See the docs on [gtk.scrollbar.Scrollbar] for the details, but note that the “step_increment” and “page_increment” fields are only effective if the policy causes scrollbars to be present.
If a [gtk.scrolled_window.ScrolledWindow] doesn’t behave quite as you would like, or doesn’t have exactly the right layout, it’s very possible to set up your own scrolling with [gtk.scrollbar.Scrollbar] and for example a [gtk.grid.Grid].
Touch support
[gtk.scrolled_window.ScrolledWindow] has built-in support for touch devices. When a touchscreen is used, swiping will move the scrolled window, and will expose 'kinetic' behavior. This can be turned off with the property@Gtk.ScrolledWindow:kinetic-scrolling property if it is undesired.
[gtk.scrolled_window.ScrolledWindow] also displays visual 'overshoot' indication when the content is pulled beyond the end, and this situation can be captured with the signal@Gtk.ScrolledWindow::edge-overshot signal.
If no mouse device is present, the scrollbars will overlaid as narrow, auto-hiding indicators over the content. If traditional scrollbars are desired although no mouse is present, this behaviour can be turned off with the property@Gtk.ScrolledWindow:overlay-scrolling property.
CSS nodes
[gtk.scrolled_window.ScrolledWindow] has a main CSS node with name scrolledwindow. It gets a .frame style class added when property@Gtk.ScrolledWindow:has-frame is true.
It uses subnodes with names overshoot and undershoot to draw the overflow and underflow indications. These nodes get the .left, .right, .top or .bottom style class added depending on where the indication is drawn.
[gtk.scrolled_window.ScrolledWindow] also sets the positional style classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars.
If both scrollbars are visible, the area where they meet is drawn with a subnode named junction.
Accessibility
Until GTK 4.10, [gtk.scrolled_window.ScrolledWindow] used the [gtk.types.AccessibleRole.Group] role.
Starting from GTK 4.12, [gtk.scrolled_window.ScrolledWindow] uses the [gtk.types.AccessibleRole.Generic] role.
ScrolledWindow self()Returns `this`, for use in `with` statements.ScrolledWindowGidBuilder builder()Get builder for [gtk.scrolled_window.ScrolledWindow] Returns: New builder objectvoid child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.gtk.adjustment.Adjustment hadjustment() @propertyvoid hadjustment(gtk.adjustment.Adjustment propval) @propertybool hasFrame() @propertyGet `hasFrame` property. Returns: Whether to draw a frame around the contents.void hasFrame(bool propval) @propertySet `hasFrame` property. Params: propval = Whether to draw a frame around the contents.gtk.types.PolicyType hscrollbarPolicy() @propertyGet `hscrollbarPolicy` property. Returns: When the horizontal scrollbar is displayed.void hscrollbarPolicy(gtk.types.PolicyType propval) @propertySet `hscrollbarPolicy` property. Params: propval = When the horizontal scrollbar is displayed.bool kineticScrolling() @propertyGet `kineticScrolling` property. Returns: Whether kinetic scrolling is enabled or not.void kineticScrolling(bool propval) @propertySet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not.int maxContentHeight() @propertyGet `maxContentHeight` property. Returns: The maximum content height of @scrolled_window.void maxContentHeight(int propval) @propertySet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window.int maxContentWidth() @propertyGet `maxContentWidth` property. Returns: The maximum content width of @scrolled_window.void maxContentWidth(int propval) @propertySet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window.int minContentHeight() @propertyGet `minContentHeight` property. Returns: The minimum content height of @scrolled_window.void minContentHeight(int propval) @propertySet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window.int minContentWidth() @propertyGet `minContentWidth` property. Returns: The minimum content width of @scrolled_window.void minContentWidth(int propval) @propertySet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window.bool overlayScrolling() @propertyGet `overlayScrolling` property. Returns: Whether overlay scrolling is enabled or not.void overlayScrolling(bool propval) @propertySet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not.bool propagateNaturalHeight() @propertyGet `propagateNaturalHeight` property. Returns: Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void propagateNaturalHeight(bool propval) @propertySet `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.bool propagateNaturalWidth() @propertyGet `propagateNaturalWidth` property. Returns: Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void propagateNaturalWidth(bool propval) @propertySet `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.gtk.adjustment.Adjustment vadjustment() @propertyvoid vadjustment(gtk.adjustment.Adjustment propval) @propertygtk.types.PolicyType vscrollbarPolicy() @propertyGet `vscrollbarPolicy` property. Returns: When the vertical scrollbar is displayed.void vscrollbarPolicy(gtk.types.PolicyType propval) @propertySet `vscrollbarPolicy` property. Params: propval = When the vertical scrollbar is displayed.gtk.types.CornerType windowPlacement() @propertyGet `windowPlacement` property. Returns: Where the contents are located with respect to the scrollbars.void windowPlacement(gtk.types.CornerType propval) @propertySet `windowPlacement` property. Params: propval = Where the contents are located with respect to the scrollbars.gtk.widget.Widget getChild()Gets the child widget of scrolled_window.gtk.adjustment.Adjustment getHadjustment()Returns the horizontal scrollbar’s adjustment.bool getHasFrame()Gets whether the scrolled window draws a frame. Returns: true if the scrolled_window has a framegtk.widget.Widget getHscrollbar()Returns the horizontal scrollbar of scrolled_window. Returns: the horizontal scrollbar of the scrolled window.bool getKineticScrolling()Returns the specified kinetic scrolling behavior. Returns: the scrolling behavior flags.int getMaxContentHeight()Returns the maximum content height set. Returns: the maximum content height, or -1int getMaxContentWidth()Returns the maximum content width set. Returns: the maximum content width, or -1int getMinContentHeight()Gets the minimal content height of scrolled_window. Returns: the minimal content heightint getMinContentWidth()Gets the minimum content width of scrolled_window. Returns: the minimum content widthbool getOverlayScrolling()Returns whether overlay scrolling is enabled for this scrolled window. Returns: true if overlay scrolling is enabledgtk.types.CornerType getPlacement()Gets the placement of the contents with respect to the scrollbars. Returns: the current placement value.void getPolicy(out gtk.types.PolicyType hscrollbarPolicy, out gtk.types.PolicyType vscrollbarPolicy)Retrieves the current policy values for the horizontal and vertical scrollbars.bool getPropagateNaturalHeight()Reports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height. Returns: whether natural height propagation is enabled.bool getPropagateNaturalWidth()Reports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width. Returns: whether natural width propagation is enabled.gtk.adjustment.Adjustment getVadjustment()Returns the vertical scrollbar’s adjustment.gtk.widget.Widget getVscrollbar()Returns the vertical scrollbar of scrolled_window. Returns: the vertical scrollbar of the scrolled window.void setChild(gtk.widget.Widget child = null)Sets the child widget of scrolled_window.void setHadjustment(gtk.adjustment.Adjustment hadjustment = null)Sets the [gtk.adjustment.Adjustment] for the horizontal scrollbar.void setHasFrame(bool hasFrame)Changes the frame drawn around the contents of scrolled_window.void setKineticScrolling(bool kineticScrolling)Turns kinetic scrolling on or off.void setMaxContentHeight(int height)Sets the maximum height that scrolled_window should keep visible.void setMaxContentWidth(int width)Sets the maximum width that scrolled_window should keep visible.void setMinContentHeight(int height)Sets the minimum height that scrolled_window should keep visible.void setMinContentWidth(int width)Sets the minimum width that scrolled_window should keep visible.void setOverlayScrolling(bool overlayScrolling)Enables or disables overlay scrolling for this scrolled window.void setPlacement(gtk.types.CornerType windowPlacement)Sets the placement of the contents with respect to the scrollbars for the scrolled window.void setPolicy(gtk.types.PolicyType hscrollbarPolicy, gtk.types.PolicyType vscrollbarPolicy)Sets the scrollbar policy for the horizontal and vertical scrollbars.void setPropagateNaturalHeight(bool propagate)Sets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void setPropagateNaturalWidth(bool propagate)Sets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void setVadjustment(gtk.adjustment.Adjustment vadjustment = null)Sets the [gtk.adjustment.Adjustment] for the vertical scrollbar.void unsetPlacement()Unsets the placement of the contents with respect to the scrollbars.gulong connectEdgeOvershot(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.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `EdgeOvershot` signal.gulong connectEdgeReached(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.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `EdgeReached` signal.gulong connectMoveFocusOut(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.DirectionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `MoveFocusOut` signal.gulong connectScrollChild(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.types.ScrollType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == bool)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 4)Connect to `ScrollChild` signal.T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget.T hadjustment(gtk.adjustment.Adjustment propval)T hasFrame(bool propval)Set `hasFrame` property. Params: propval = Whether to draw a frame around the contents. Returns: Builder instance for fluent chainingT hscrollbarPolicy(gtk.types.PolicyType propval)Set `hscrollbarPolicy` property. Params: propval = When the horizontal scrollbar is displayed.T kineticScrolling(bool propval)Set `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not.T maxContentHeight(int propval)Set `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window. Returns: Builder instance for fluent chainingT maxContentWidth(int propval)Set `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window. Returns: Builder instance for fluent chainingT minContentHeight(int propval)Set `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window. Returns: Builder instance for fluent chainingT minContentWidth(int propval)Set `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window. Returns: Builder instance for fluent chainingT overlayScrolling(bool propval)Set `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not.T propagateNaturalHeight(bool propval)Set `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.T propagateNaturalWidth(bool propval)Set `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.T vadjustment(gtk.adjustment.Adjustment propval)T vscrollbarPolicy(gtk.types.PolicyType propval)Set `vscrollbarPolicy` property. Params: propval = When the vertical scrollbar is displayed.T windowPlacement(gtk.types.CornerType propval)Set `windowPlacement` property. Params: propval = Where the contents are located with respect to the scrollbars. Returns: Builder instance for fluent chainingFluent builder for [gtk.scrolled_window.ScrolledWindow]