gtk.SizeGroup
Prev | The gtk Class Reference | Next

## gtk.SizeGroup

gtk.SizeGroup — an object that groups widgets so they request the same size

## Synopsis

    class gtk.SizeGroup(gobject.GObject):
        gtk.SizeGroup(mode)
        def set_mode(mode)
        def get_mode()
        def set_ignore_hidden(ignore_hidden)
        def get_ignore_hidden()
        def add_widget(widget)
        def remove_widget(widget)
        def get_widgets()

## Ancestry

    +-- gobject.GObject
      +-- gtk.SizeGroup

## Implemented Interfaces

`gtk.SizeGroup` implements `gtk.Buildable`

## gtk.SizeGroup Properties

"ignore-hidden" | Read-Write | If `True`, hidden widgets are ignored when determining the size of the group. Default value: `False`. Available in GTK+ 2.8 and above.
"mode" | Read-Write | The directions in which the size group effects the requested sizes of its component widgets - one of the GTK SizeGroup Mode Constants. Default value: `gtk.SIZE_GROUP_HORIZONTAL`.

## gtk.SizeGroup Signal Prototypes

gobject.GObject Signal Prototypes

## Description

`gtk.SizeGroup` provides a mechanism for grouping a number of widgets together so they all request the same amount of space. This is typically useful when you want a column of widgets to have the same size, but you can't use a `gtk.Table` widget. The size requested for each widget in a `gtk.SizeGroup` is the maximum of the sizes that would have been requested for each widget in the size group if they were not in the size group. The mode of the size group (see `set_mode`() and the GTK SizeGroup Mode Constants) determines whether this applies to the horizontal size, the vertical size, or both sizes:

Note that size groups only affect the amount of space requested, not the size that the widgets finally receive. If you want the widgets in a `gtk.SizeGroup` to actually be the same size, you need to pack them in such a way that they get the size they request and not more. For example, if you are packing your widgets into a table, you would not include the `gtk.FILL` flag. `gtk.SizeGroup` objects are referenced by each widget in the size group, so once you have added all widgets to a `gtk.SizeGroup`. If the widgets in the size group are subsequently destroyed, then they will be removed from the size group and drop their references on the size group; when all widgets have been removed, the size group will be freed.

Widgets can be part of multiple size groups; PyGTK will compute the horizontal size of a widget from the horizontal requisition of all widgets that can be reached from the widget by a chain of size groups of type `gtk.SIZE_GROUP_HORIZONTAL` or `gtk.SIZE_GROUP_BOTH`, and the vertical size from the vertical requisition of all widgets that can be reached from the widget by a chain of size groups of type `gtk.SIZE_GROUP_VERTICAL` or `gtk.SIZE_GROUP_BOTH`.

## Constructor

        gtk.SizeGroup(mode)

`mode` : | the mode for the new size group.
Returns : | a new `gtk.SizeGroup`

Creates a new `gtk.SizeGroup` with the mode specified by the value of `mode` which is one of the GTK SizeGroup Mode Constants.

## Methods

### gtk.SizeGroup.set_mode

        def set_mode(mode)

`mode` : | the mode to set for the size group.

The `set_mode`() method sets the "mode" property of the size group to the value specified by `mode`. The "mode" of the size group determines whether the widgets in the size group should all have the same horizontal requisition (see the GTK SizeGroup Mode Constants).

### gtk.SizeGroup.get_mode

        def get_mode()

Returns : | the current mode of the size group.

The `get_mode`() method returns the value of the "mode" property of the size group. See the `set_mode`() method.

### gtk.SizeGroup.set_ignore_hidden

        def set_ignore_hidden(ignore_hidden)

`ignore_hidden` : | If `True` hidden widgets should be ignored when calculating the size

### Note

This method is available in PyGTK 2.8 and above.

The `set_ignore_hidden`() method sets the "ignore-hidden" property to the value of `ignore_hidden`. If `ignore_hidden` is `True` invisible widgets will be ignored when calculating size.

### gtk.SizeGroup.get_ignore_hidden

        def get_ignore_hidden()

Returns : | `True` if hidden widgets are ignored in size calculations.

### Note

This method is available in PyGTK 2.8 and above.

The `get_ignore_hidden`() method returns the value of the "ignore-hidden" property of the size group. If "ignore-hidden" is `True`, invisible widgets are ignored in size calculations.

### gtk.SizeGroup.add_widget

        def add_widget(widget)

`widget` : | the `gtk.Widget` to add

The `add_widget`() method adds the widget specified by `widget` to the `gtk.SizeGroup`. The requisition of the widget will then be determined as the maximum of its requisition and the requisition of the other widgets in the size group. Whether this applies horizontally, vertically, or in both directions depends on the mode of the size group. See the `set_mode`() method for more detail.

### gtk.SizeGroup.remove_widget

        def remove_widget(widget)

`widget` : | the `gtk.Widget` to remove

The remove_widget() method removes the widget specified by widget from the `gtk.SizeGroup`.

### gtk.SizeGroup.get_widgets

        def get_widgets()

Returns : | a list of widgets.

The `get_widgets`() method returns the list of widgets associated with size_group.

Prev | Up | Next
gtk.Settings | Home | gtk.Socket