A Layout provides an infinite scrolling area for child widgets to be placed on. It can also be used as a surface for custom drawings to be displayed.

If the size of the scrolling area is going to be known before running, it is suggested that a Fixed is used.


The Layout can be constructed using the following:

layout = Gtk.Layout(hadjustment, vadjustment)

The hadjustment and vadjustment parameters should be set to an Adjustment object which stores the values of the scrollbars.


To position widgets on the Layout use:

layout.put(widget, x, y)

The widget parameter specifies the widget which is to be drawn on the Layout. The x and y values are the co-ordinates of where to place the widget.

Widges can be moved after calling .put() with:

layout.move(widget, x, y)

To set the size of the Layout call:

layout.set_size(width, height)

Alternatively, to retrieve the Layout size use:

size = layout.get_size()

The Adjustment objects can be specified after constructing the Layout with:



Below is an example of a Layout:

#!/usr/bin/env python3

from gi.repository import Gtk

class Layout(Gtk.Window):
    def __init__(self):
        self.set_default_size(200, 200)
        self.connect("destroy", Gtk.main_quit)

        layout = Gtk.Layout()

        button = Gtk.Button(label="Button 1")
        layout.put(button, 40, 60)
        button = Gtk.Button(label="Button 2")
        layout.put(button, 120, 95)

window = Layout()


Download: Layout