traitsui.group module

Defines the Group class used to represent a group of items used in a Traits-based user interface.

class traitsui.group.Group(*values, **traits)[source]

Bases: ViewSubElement

Represents a grouping of items in a user interface view.

columns = Range(1, 50)

The number of columns in the group

content = List(ViewSubElement)

A list of Group, Item, and Include objects in this group.

defined_when = Str()

Pre-condition for including the group in the display. If the expression evaluates to False, the group is not defined in the display. Conditions for defined_when are evaluated only once, when the display is first constructed. Use this attribute for conditions based on attributes that vary from object to object, but that do not change over time.

dock = ContainerDelegate

Default docking style of items in group.

dock_theme = Instance(DockWindowTheme, allow_none=False)

The theme to use for a DockWindow:

enabled_when = Str()

Pre-condition for enabling the group. If the expression evaluates to False, the group is disabled, that is, none of the widgets accept input. All enabled_when conditions are checked each time that any trait value on an object in the UI’s context is changed. Therefore, you can use enabled_when conditions to enable or disable groups in response to user input. Be aware that this only applies to traits in the UI’s context. As a result, changes to nested traits that don’t also change a trait on some object in the context may not trigger the expression to be checked. Additionally, the expression needs to be a valid python expression given the context. i.e. eval(enabled_when, globals=globals(), locals=context) should succeed.

export = ContainerDelegate

Category of elements dragged from view.

get_label(ui)[source]

Gets the label to use this group.

get_shadow(ui)[source]

Returns a ShadowGroup object for the current Group object, which recursively resolves all embedded Include objects and which replaces each embedded Group object with a corresponding ShadowGroup.

height = Property(Float, observe="content")

Requested height of the group (calculated from heights of contents)

help = Str()

Optional help text (for top-level group). This help text appears in the View-level help window (created by the default help handler), for any View that contains only this group. Group-level help is ignored for nested groups and multiple top-level groups

id = Str()

A unique identifier for the group.

image = ContainerDelegate

Default image to display on notebook tabs.

is_includable()[source]

Returns a Boolean value indicating whether the object is replacable by an Include object.

label = Str()

User interface label for the group. How the label is displayed depends on the show_border attribute, and on the layout attribute of the group’s parent group or view.

layout = Layout

Layout style of the group, which can be one of the following:

  • ‘normal’ (default): Sub-groups are displayed sequentially in a single panel.

  • ‘flow’: Sub-groups are displayed sequentially, and then “wrap” when they exceed the available space in the orientation direction.

  • ‘split’: Sub-groups are displayed in a single panel, separated by “splitter bars”, which the user can drag to adjust the amount of space for each sub-group.

  • ‘tabbed’: Each sub-group appears on a separate tab, labeled with the sub-group’s label text, if any.

This attribute is ignored for groups that contain only items, or contain only one sub-group.

object = ContainerDelegate

Default context object for group items.

orientation = Orientation

Spatial orientation of the group’s elements. Can be ‘vertical’ (default) or ‘horizontal’.

padding = Padding

Amount of padding (in pixels) to add around each item in the group. The value must be an integer between 0 and 15. (Unlike the Item class, the Group class does not support negative padding.) The padding for any individual widget is the sum of the padding for its Group, the padding for its Item, and the default spacing determined by the toolkit.

replace_include(view_elements)[source]

Replaces any items that have an id attribute with an Include object with the same ID value, and puts the object with the ID into the specified ViewElements object.

Parameters:

view_elements (ViewElements object) – A set of Group, Item, and Include objects

scrollable = Bool(False)

Should the group be scrollable along the direction of orientation?

selected = Bool(False)

Is this group the tab that is initially selected? If True, the group’s tab is displayed when the view is opened. If the layout of the group’s parent is not ‘tabbed’, this attribute is ignored.

set_container()[source]

Sets the correct container for the content.

show_border = Bool(False)

Should a border be drawn around group? If set to True, the label text is embedded in the border. If set to False, the label appears as a banner above the elements of the group.

show_labels = Bool(True)

Should labels be added to items in group? Only items that are directly contained in the group are affected. That is, if the group contains a sub-group, the display of labels in the sub-group is not affected by the attribute on this group.

show_left = Bool(True)

Should labels be shown to the left of items (True) or the right (False)? Only items that are directly contained in the group are affected. That is, if the group contains a sub-group, the display of labels in the sub-group is not affected by the attribute in this group. If show_labels is False, this attribute is irrelevant.

springy = Bool(False)

Should the group use extra space along its parent group’s layout orientation?

style = ContainerDelegate

Default editor style of items in the group.

visible_when = Str()

Pre-condition for showing the group. If the expression evaluates to False, the group and its items are not visible (and they disappear if they were previously visible). If the value evaluates to True, the group and items become visible. All visible_when conditions are checked each time that any trait value on an object in the UI’s context is changed. Therefore, you can use visible_when conditions to hide or show groups in response to user input. Be aware that this only applies to traits in the UI’s context. As a result, changes to nested traits that don’t also change a trait on some object in the context may not trigger the expression to be checked. Additionally, the expression needs to be a valid python expression given the context. i.e. eval(visible_when, globals=globals(), locals=context) should succeed.

width = Property(Float, observe="content")

Requested width of the group (calculated from widths of contents)

class traitsui.group.HFlow(*values, **traits)[source]

Bases: HGroup

A group in which items are laid out horizontally, and “wrap” when they exceed the available horizontal space..

layout = "flow"

Override standard Group trait defaults to give it horizontal flow behavior:

class traitsui.group.HGroup(*values, **traits)[source]

Bases: Group

A group whose items are laid out horizontally.

orientation = "horizontal"

Override standard Group trait defaults to give it horizontal group behavior:

class traitsui.group.HSplit(*values, **traits)[source]

Bases: Group

A horizontal group with splitter bars to separate it from other groups.

layout = "split"

Override standard Group trait defaults to give it horizontal splitter behavior:

class traitsui.group.ShadowGroup(shadow, **traits)[source]

Bases: Group

Corresponds to a Group object, but with all embedded Include objects resolved, and with all embedded Group objects replaced by corresponding ShadowGroup objects.

columns = ShadowDelegate

The number of columns in the group

defined_when = ShadowDelegate

Pre-condition for defining the group

dock = ShadowDelegate

Default docking style of items in the group

dock_theme = ShadowDelegate

The theme to use for a DockWindow:

enabled_when = ShadowDelegate

Pre-condition for enabling the group

export = ShadowDelegate

Category of elements dragged from the view

get_content(allow_groups=True)[source]

Returns the contents of the Group within a specified context for building a user interface.

This method makes sure that all Group types are of the same type (i.e., Group or Item) and that all Include objects have been replaced by their substituted values.

get_id()[source]

Returns an ID for the group.

groups = ReadOnly()

Number of ShadowGroups in content

help = ShadowDelegate

Optional help text (for top-level group)

id = ShadowDelegate

Name of the group

image = ShadowDelegate

Default image to display on notebook tabs

label = ShadowDelegate

User interface label for the group

layout = ShadowDelegate

Layout style of the group

object = ShadowDelegate

Default context object for group items

orientation = ShadowDelegate

Spatial orientation of the group

padding = ShadowDelegate

Amount of padding to add around each item

scrollable = ShadowDelegate

Should the group be scrollable along the direction of orientation?

selected = ShadowDelegate

Is group the initially selected page?

set_container()[source]

Sets the correct container for the content.

shadow = shadow

Group object this is a “shadow” for

show_border = ShadowDelegate

Should a border be drawn around group?

show_labels = ShadowDelegate

Should labels be added to items in group?

show_left = ShadowDelegate

Should labels be shown to the left of items (vs. the right)?

springy = ShadowDelegate

Should the group use extra space along its parent group’s layout orientation?

style = ShadowDelegate

Default style of items in the group

style_sheet = ShadowDelegate

Style sheet for the panel

visible_when = ShadowDelegate

Pre-condition for showing the group

class traitsui.group.Tabbed(*values, **traits)[source]

Bases: Group

A group that is shown as a tabbed notebook.

layout = "tabbed"

Override standard Group trait defaults to give it tabbed notebook behavior:

class traitsui.group.VFlow(*values, **traits)[source]

Bases: VGroup

A group in which items are laid out vertically, and “wrap” when they exceed the available vertical space.

layout = "flow"

Override standard Group trait defaults to give it vertical flow behavior:

class traitsui.group.VFold(*values, **traits)[source]

Bases: VGroup

A group in which items are laid out vertically and can be collapsed (i.e. ‘folded’) by clicking their title.

layout = "fold"

Override standard Group trait defaults to give it vertical folding group behavior:

class traitsui.group.VGrid(*values, **traits)[source]

Bases: VGroup

A group whose items are laid out in 2 columns.

columns = 2

Override standard Group trait defaults to give it grid behavior:

class traitsui.group.VGroup(*values, **traits)[source]

Bases: Group

A group whose items are laid out vertically.

orientation = "vertical"

Override standard Group trait defaults to give it vertical group behavior:

class traitsui.group.VSplit(*values, **traits)[source]

Bases: Group

A vertical group with splitter bars to separate it from other groups.

layout = "split"

Override standard Group trait defaults to give it vertical splitter behavior: