gtk.Alignment — a widget that controls the alignment and size of its child
class gtk.Alignment(gtk.Bin): |
+--gobject.GObject +-- gtk.Object +-- gtk.Widget +-- gtk.Container +-- gtk.Bin +-- gtk.Alignment
|
The gtk.Alignment
widget controls the alignment and size of its child widget. It has four
properties: xscale, yscale, xalign, and yalign. The scale properties are
used to specify how much of the free (extra) space
allocated to the gtk.Alignment
should be absorbed by the child widget. The values can range from 0.0
(meaning the child absorbs none) to 1.0 (meaning the child absorbs all of
the free space). If the value is 0.5, the child widget
absorbs half the free space. The align properties are
used to place the child widget within the available area by specifying the
fraction of free space that will be placed above or to
the left of the child widget. The values range from 0.0 (no
free space above or to the left of the child) to 1.0
(all free space above or to the left of the child). Of
course, if the scale properties are both set to 1.0, the alignment
properties have no effect.
An example may make this clearer. A gtk.Button
widget (32
pixels wide by 32 pixels high) is placed inside a gtk.Alignment
widget (256 pixels wide by 128 pixels high) which has xalign of 0.25, yalign
of 0.25, xscale of 0.25 and yscale of 0.25. The horizontal
free space is 256-32=224 pixels and the vertical
free space is 128-32=96 pixels. The button will absorb
0.25x224=56 pixels horizontally and 0.25x96=24 pixels vertically since the
xscale and yscale are 0.25 thus becoming 32+56=88 pixels wide by 32+24=56
pixels high. This will leave 256-88=168 pixels of horizontal
free space and 128-56=72 pixels of vertical
free space. Since the xalign value is 0.25 the
horizontal free space will be allocated as 0.25x168=42
pixels to the left of the button and 0.72x168=126 pixels to the right.
Likewise since the yalign is 0.25 the vertical free
space is allocated as 0.25x72=18 pixels above the button and 0.75*72=54
pixels below.
gtk.Alignment(xalign
=0.0, yalign
=0.0, xscale
=0.0, yscale
=0.0)
| the fraction of horizontal free space to the left of the child widget. Ranges from 0.0 to 1.0 |
| the fraction of vertical free space above the child widget. Ranges from 0.0 to 1.0 |
| the fraction of horizontal free space that the child widget absorbs, from 0.0 to 1.0 |
| the fraction of vertical free space that the child widget absorbs, from 0.0 to 1.0 |
Returns : | a new alignment object |
Creates a new alignment widget with the specified properties. If the scale and alignment parameters are not specified they default to 0.0.
def set(xalign
, yalign
, xscale
, yscale
)
| the fraction of horizontal free space to the left of the child widget. Ranges from 0.0 to 1.0 |
| the fraction of vertical free space above the child widget. Ranges from 0.0 to 1.0 |
| the fraction of horizontal free space that the child widget absorbs, from 0.0 to 1.0 |
| the fraction of vertical free space that the child widget absorbs, from 0.0 to 1.0 |
The set
() method sets the properties of
the alignment widget to the specified values.
def set_padding(padding_top
, padding_bottom
, padding_left
, padding_right
)
| the padding at the top of the widget |
| the padding at the bottom of the widget |
| the padding at the left of the widget |
| the padding at the right of the widget. |
This method is available in PyGTK 2.4 and above.
The set_padding
() method sets the
padding around the sides of the alignment widget to the values specified by
padding_top
, padding_bottom
,
padding_left
and
padding_right
. The padding adds blank space to the
sides of the widget. For instance, this can be used to indent the child
widget toward the right by adding padding on the left.