PyGTK Layout Class - PyGTK

What is PyGTK Layout Class?

The gtk.Layout is a container widget alike to gtk.Fixed. Widgets are located in Layout widget by stating absolute coordinates. Though, the Layout differs from fixed widget in the resulting ways −

  • The layout widget can have infinite width and height. The maximum value of width and height is limited by the size of unsigned integer.
  • A gtk.DrawingArea widget can be enclosed in a layout container. The DrawingArea is a canvas on which 2D elements like line, rectangle etc. can be drawn.
  • In order to put the Layout container in the toplevel window of lesser dimensions, it can be associated with the scrollbars or can be placed in a ScrolledWindow.

The gtk.Layout class has the following constructor –

The hadjustment and vadjustment properties represent an object having an adjustable bounded value.

The resulting table lists out the often used methods of the layout −

put(widget, x, y)

Places a child widget at the specified coordinates

set_size(w, h)

Sets the size of the Layout container to the specified width and height

The Layout object emits the set_scroll_adjustment signal when the adjustments associated with it are changed.

Example

In the resulting instance, a Label is stepped at the centre of a Layout container, which in turn is to be placed in a toplevel window of smaller size. Therefore, it is first added to a ScrolledWindow and the ScrolledWindow is then added to the main window.

Observe the code –

The above code will generate the resulting output –

layout

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PyGTK Topics