pyface.action.group module

A group of action manager items.

class pyface.action.group.Group(*items, **traits)[source]

Bases: traits.has_traits.HasTraits

A group of action manager items.

By default, a group declares itself as requiring a separator when it is visualized, but this can be changed by setting its ‘separator’ trait to False.

enabled = Bool(True)

Is the group enabled?

visible = Bool(True)

Is the group visible?

id = Str()

The group’s unique identifier (only needs to be unique within the action manager that the group belongs to).

items = Property

All of the items in the group.

parent = Any # Instance('pyface.action.ActionManager')

The action manager that the group belongs to.

separator = Bool(True)

Does this group require a separator when it is visualized?

append(item)[source]

Appends an item to the group.

Parameters

item (ActionManagerItem, Action or callable) – The item to append.

Returns

item – The actually inserted item.

Return type

ActionManagerItem

Notes

If the item is an ActionManagerItem instance it is simply appended. If the item is an Action instance, an ActionItem is created for the action, and that is appended. If the item is a callable, then an Action is created for the callable, and then that is handled as above.

clear()[source]

Remove all items from the group.

destroy()[source]

Called when the manager is no longer required.

By default this method simply calls ‘destroy’ on all items in the group.

insert(index, item)[source]

Inserts an item into the group at the specified index.

Parameters
  • index (int) – The position to insert the item.

  • item (ActionManagerItem, Action or callable) – The item to insert.

Returns

item – The actually inserted item.

Return type

ActionManagerItem

Notes

If the item is an ActionManagerItem instance it is simply inserted. If the item is an Action instance, an ActionItem is created for the action, and that is inserted. If the item is a callable, then an Action is created for the callable, and then that is handled as above.

remove(item)[source]

Removes an item from the group.

Parameters

item (ActionManagerItem) – The item to remove.

insert_before(before, item)[source]

Inserts an item into the group before the specified item.

Parameters
Returns

index, item – The position inserted, and the item actually inserted.

Return type

int, ActionManagerItem

Notes

If the item is an ActionManagerItem instance it is simply inserted. If the item is an Action instance, an ActionItem is created for the action, and that is inserted. If the item is a callable, then an Action is created for the callable, and then that is handled as above.

insert_after(after, item)[source]

Inserts an item into the group after the specified item.

Parameters
Returns

index, item – The position inserted, and the item actually inserted.

Return type

int, ActionManagerItem

Notes

If the item is an ActionManagerItem instance it is simply inserted. If the item is an Action instance, an ActionItem is created for the action, and that is inserted. If the item is a callable, then an Action is created for the callable, and then that is handled as above.

find(id)[source]

Find the item with the specified id.

Parameters

id (str) – The id of the item

Returns

item – The item with the specified Id, or None if no such item exists.

Return type

ActionManagerItem

classmethod factory(*args, **kwargs)[source]

Create a factory for a group with the given arguments.

This is particularly useful for passing context to Tasks schema additions.

class pyface.action.group.Separator(*items, **traits)[source]

Bases: pyface.action.group.Group

A convenience class.

This is only used in ‘cheap and cheerful’ applications that create menus like:

file_menu = MenuManager(
    CopyAction(),
    Separator(),
    ExitAction()
)

Hopefully, ‘Separator’ is more readable than ‘Group’…