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 add_widget(widget)
def remove_widget(widget)

Ancestry

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

Properties

"mode"Read-WriteThe directions in which the size group effects the requested sizes of its component widgets - one of: gtk.SIZE_GROUP_NONE, gtk.SIZE_GROUP_HORIZONTAL, gtk.SIZE_GROUP_VERTICAL, gtk.SIZE_GROUP_BOTH.

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()) determines whether this applies to the horizontal size, the vertical size, or both sizes:

gtk.SIZE_GROUP_NONEthe group has no effect
gtk.SIZE_GROUP_HORIZONTALthe group affects the horizontal requisition
gtk.SIZE_GROUP_VERTICALthe group affects the vertical requisition
gtk.SIZE_GROUP_BOTHthe group affects both the horizontal and vertical requisition

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:

gtk.SIZE_GROUP_NONEthe group has no effect
gtk.SIZE_GROUP_HORIZONTALthe group affects the horizontal requisition
gtk.SIZE_GROUP_VERTICALthe group affects the vertical requisition
gtk.SIZE_GROUP_BOTHthe group affects both the horizontal and vertical requisition

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 (gtk.SIZE_GROUP_MODE_HORIZONTAL) all have the same vertical requisition (gtk.SIZE_GROUP_MODE_VERTICAL), or should all have the same requisition in both directions (gtk.SIZE_GROUP_MODE_BOTH).

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.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.