PyGTK AspectFrame Class - PyGTK

What is PyGTK AspectFrame Class?

gtk.AspectFrame class is a subclass of the Frame class. The child widget in this frame continuously recalls its aspect ratio (of width and height) even if the main window is resized.

The ratio property of gtk.AspectFrame widget determines the widget width:height ratio. An aspect ratio of 0.5 means the width is one half the height; an aspect ratio of 2.0 means the width is twice the height. The default value for the "ratio" property is 1.0.

The resulting syntax is used for the constructor of gtk.AspectFrame class –

The xalign property controls the fraction of horizontal free space to the left of the child. 0.0 means no free space to the left, 1.0 means all free space to the left.

The yalign property decides the fraction of vertical free space above the child. 0.0 means no free space above, 1.0 means all free space above.
Ratio of width to height of frame is maintained if obey_child property is False.

The obey_child property determines if the ratio is to be ignored. The default is True.

The resulting code is similar to the one used for the Frame class. The only difference is that the ButonBox is placed in an AspectFrame widget.

Note − The obey_child property is set to False because it is chosen to retain the aspect ratio even if the window is resized.


Observe the resulting code –

The overhead code will create the resulting original and resized windows –


Original Window

Resized Window

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

PyGTK Topics