gtk.Alignment
Prev | The gtk Class Reference | Next

## gtk.Alignment

gtk.Alignment — a widget that controls the alignment and size of its child

## Synopsis

    class gtk.Alignment(gtk.Bin):
        gtk.Alignment(xalign=0.0, yalign=0.0, xscale=0.0, yscale=0.0)
        def set(xalign, yalign, xscale, yscale)
        def set_padding(padding_top, padding_bottom, padding_left, padding_right)
        def get_padding()

## Ancestry

    +-- gobject.GObject
      +-- gtk.Object
        +-- gtk.Widget
          +-- gtk.Container
            +-- gtk.Bin
              +-- gtk.Alignment

## Implemented Interfaces

`gtk.Alignment` implements `gtk.Buildable`

## gtk.Alignment Properties

gtk.Object Properties

gtk.Widget Properties

gtk.Container Properties

"bottom-padding" | Read/Write | The padding to insert at the bottom of the widget. GTK+ 2.4 and above.
"left-padding" | Read/Write | The padding to insert at the left of the widget. GTK+ 2.4 and above.
"right-padding" | Read/Write | The padding to insert at the right of the widget. GTK+ 2.4 and above.
"top-padding" | Read/Write | The padding to insert at the top of the widget. GTK+ 2.4 and above.
"xalign" | Read/Write | 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.
"xscale" | Read/Write | The fraction of horizontal free space (beyond that needed by the child) that the child will absorb. 0.0 means the child will absorb none, 1.0 means the child will absorb all
"yalign" | Read/Write | The fraction of vertical free space above the child. 0.0 means no free space above, 1.0 means all free space above.
"yscale" | Read/Write | The fraction of vertical free space (beyond that needed by the child) that the child will absorb. 0.0 means the child will absorb none, 1.0 means the child will absorb all

## gtk.Alignment Style Properties

gtk.Widget Style Properties

## gtk.Alignment Signal Prototypes

gobject.GObject Signal Prototypes

gtk.Object Signal Prototypes

gtk.Widget Signal Prototypes

gtk.Container Signal Prototypes

## Description

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.

## Constructor

        gtk.Alignment(xalign=0.0, yalign=0.0, xscale=0.0, yscale=0.0)

`xalign` : | the fraction of horizontal free space to the left of the child widget. Ranges from 0.0 to 1.0
`yalign` : | the fraction of vertical free space above the child widget. Ranges from 0.0 to 1.0
`xscale` : | the fraction of horizontal free space that the child widget absorbs, from 0.0 to 1.0
`yscale` : | 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.

## Methods

### gtk.Alignment.set

        def set(xalign, yalign, xscale, yscale)

`xalign` : | the fraction of horizontal free space to the left of the child widget. Ranges from 0.0 to 1.0
`yalign` : | the fraction of vertical free space above the child widget. Ranges from 0.0 to 1.0
`xscale` : | the fraction of horizontal free space that the child widget absorbs, from 0.0 to 1.0
`yscale` : | 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.

### gtk.Alignment.set_padding

        def set_padding(padding_top, padding_bottom, padding_left, padding_right)

`padding_top` : | the padding at the top of the widget
`padding_bottom` : | the padding at the bottom of the widget
`padding_left` : | the padding at the left of the widget
`padding_right` : | the padding at the right of the widget.

### Note

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.

### gtk.Alignment.get_padding

        def get_padding()

Returns : | a 4-tuple containing the padding set on the top, bottom, left and right sides of the widget

### Note

This method is available in PyGTK 2.4 and above.

The `get_padding`() method returns a 4-tuple containing the padding set on the sides of the widget.

Prev | Up | Next
gtk.Adjustment | Home | gtk.Arrow