gtk.ActionGroup
Prev | The gtk Class Reference | Next

## gtk.ActionGroup

gtk.ActionGroup — a group of actions (new in PyGTK 2.4)

## Synopsis

    class gtk.ActionGroup(gobject.GObject):
        gtk.ActionGroup(name)
        def get_name()
        def get_sensitive()
        def set_sensitive(sensitive)
        def get_visible()
        def set_visible(visible)
        def get_action(action_name)
        def list_actions()
        def add_action(action)
        def add_action_with_accel(action, accelerator)
        def remove_action(action)
        def add_actions(entries, user_data=None)
        def add_toggle_actions(entries, user_data=None)
        def add_radio_actions(entries, value=0, on_change=None, user_data=None)
        def set_translation_domain(domain)
        def translate_string(string)

## Ancestry

    +-- gobject.GObject
      +-- gtk.ActionGroup

## Implemented Interfaces

`gtk.ActionGroup` implements `gtk.Buildable`

## gtk.ActionGroup Properties

"name" | Read-Write | A name for the action group.
"sensitive" | Read-Write | If `True`, the action group is enabled.
"visible" | Read-Write | If `True`, the action group is visible.

## gtk.ActionGroup Signal Prototypes

gobject.GObject Signal Prototypes

"connect-proxy" | `def callback(`actiongroup`, `action`, `proxy`, `user_param1`, `...`)`
"disconnect-proxy" | `def callback(`actiongroup`, `action`, `proxy`, `user_param1`, `...`)`
"post-activate" | `def callback(`actiongroup`, `action`, `user_param1`, `...`)`
"pre-activate" | `def callback(`actiongroup`, `action`, `user_param1`, `...`)`

## Description

### Note

This object is available in PyGTK 2.4 and above.

`gtk.Action` objects are organized into `gtk.ActionGroup` objects. An action group is basically a map from names to `gtk.Action` objects.

All actions that would make sense to use in a particular context should be in a single action group. Multiple action groups may be used for a particular user interface. In fact, it is expected that most nontrivial applications will make use of multiple groups. For example, in an application that can edit multiple documents, there could be one group holding global actions (e.g. quit, about, new), and one group per document holding actions that act on that document (e.g. save, cut/copy/paste, etc). Each window's menus would be constructed from a combination of the two action groups.

Accelerators are handled by the GTK+ accelerator map. All actions are assigned an accelerator path (which normally has the form "<Actions>/group-name/action-name") and a shortcut is associated with this accelerator path. All menuitems and toolitems take on this accelerator path. The GTK+ accelerator map code makes sure that the correct shortcut is displayed next to the menu item.

## Constructor

        gtk.ActionGroup(name)

`name` : | the name of the action group.
Returns : | the new `gtk.ActionGroup`

### Note

This constructor is available in PyGTK 2.4 and above.

Creates a new `gtk.ActionGroup` object with the name specified by `name`. The name of the action group is used when associating keybindings with the actions.

## Methods

### gtk.ActionGroup.get_name

        def get_name()

Returns : | the name of the action group.

### Note

This method is available in PyGTK 2.4 and above.

The `get_name`() method returns the value of the "name" property that contains the name of the action group.

### gtk.ActionGroup.get_sensitive

        def get_sensitive()

Returns : | `True` if the group is sensitive.

### Note

This method is available in PyGTK 2.4 and above.

The `get_sensitive`() method returns the value of the "sensitive" property. If "sensitive" is `True` the group is enabled. The constituent actions can only be logically sensitive (see the `gtk.Action.is_sensitive()` method) if they are sensitive (see the `gtk.Action.get_sensitive()` method) and their group is sensitive.

### gtk.ActionGroup.set_sensitive

        def set_sensitive(sensitive)

`sensitive` : | if `True`, the group is enabled

### Note

This method is available in PyGTK 2.4 and above.

The `set_sensitive`() method sets the "sensitive" property to the value of `sensitive`. If `sensitive` is `True`, the `gtk.ActionGroup` is enabled.

### gtk.ActionGroup.get_visible

        def get_visible()

Returns : | `True` if the group is visible.

### Note

This method is available in PyGTK 2.4 and above.

The `get_visible`() method returns the value of the "visible" property. If "visible" is `True`, the group is visible. The constituent actions can only be logically visible (see the `gtk.Action.is_visible()` method) if they are visible (see the `gtk.Action.get_visible()` method) and their group is visible.

### gtk.ActionGroup.set_visible

        def set_visible(visible)

`visible` : | if `True`, the group will be visible

### Note

This method is available in PyGTK 2.4 and above.

The `set_visible`() method sets the "visible" property to the value of `visible`. If `visible` is `True` the `gtk.ActionGroup` will be visible.

### gtk.ActionGroup.get_action

        def get_action(action_name)

`action_name` : | the name of the action
Returns : | the action, or `None` if no action with that name exists.

### Note

This method is available in PyGTK 2.4 and above.

The `get_action`() method retrieves the action in the action group with the name specified by `action_name`.

### gtk.ActionGroup.list_actions

        def list_actions()

Returns : | a list of the action objects in the action group

### Note

This method is available in PyGTK 2.4 and above.

The `list_action`() method returns a list containing the `gtk.Action` objects in the action group.

### gtk.ActionGroup.add_action

        def add_action(action)

`action` : | an action

### Note

This method is available in PyGTK 2.4 and above.

The `add_action`() method adds the `gtk.Action` specified by `action` to the action group.

### gtk.ActionGroup.add_action_with_accel

        def add_action_with_accel(action, accelerator)

`action` : | the action to add
`accelerator` : | the accelerator for the action, in the format understood by the `gtk.accelerator_parse`() function, or `None` to use the stock accelerator

### Note

This method is available in PyGTK 2.4 and above.

The `add_action_with_accel`() method adds a `gtk.Action` specified by `action` to the action group and sets up the accelerator specified by `accelerator`.

If `accelerator` is `None`, this method attempts to use the accelerator associated with the "stock_id" property of the `gtk.Action`.

Accel paths are set to `<Actions>/`group-name`/`action-name``.

### gtk.ActionGroup.remove_action

        def remove_action(action)

`action` : | a `gtk.Action`

### Note

This method is available in PyGTK 2.4 and above.

The `remove_action`() method removes the `gtk.Action` specified by `action` from the action group.

### gtk.ActionGroup.add_actions

        def add_actions(entries, user_data=None)

`entries` : | a list or tuple of action descriptions
`user_data` : | data to pass to the action callbacks

### Note

This method is available in PyGTK 2.4 and above.

The `add_actions`() method is a convenience method that creates a number of `gtk.Action` objects based on the information in the list of action entry tuples contained in `entries` and adds them to the action group. The entry tuples can vary in size from one to six items with the following information:

- The name of the action. Must be specified.
- The stock id for the action. Optional with a default value of `None` if a label is specified.
- The label for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None` if a stock id is specified.
- The accelerator for the action, in the format understood by the `gtk.accelerator_parse`() function. Optional with a default value of `None`.
- The tooltip for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None`.
- The callback function invoked when the action is activated. Optional with a default value of `None`.

The "activate" signals of the actions are connected to the callbacks and their accel paths are set to `<Actions>/`group-name`/`action-name``.

### gtk.ActionGroup.add_toggle_actions

        def add_toggle_actions(entries, user_data=None)

`entries` : | a list or tuple of toggle action entry tuples
`user_data` : | data to pass to the action callbacks

### Note

This method is available in PyGTK 2.4 and above.

The `add_toggle_actions`() method is a convenience method that creates a number of `gtk.ToggleAction` objects based on the information in the list of action entry tuples contained in `entries` and adds them to the action group. The toggle action entry tuples can vary in size from one to seven items with the following information:

- The name of the action. Must be specified.
- The stock id for the action. Optional with a default value of `None` if a label is specified.
- The label for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None` if a stock id is specified.
- The accelerator for the action, in the format understood by the `gtk.accelerator_parse`() function. Optional with a default value of `None`.
- The tooltip for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None`.
- The callback function invoked when the action is activated. Optional with a default value of `None`.
- A flag indicating whether the toggle action is active. Optional with a default value of `False`.

The "activate" signals of the actions are connected to the callbacks and their accel paths are set to `<Actions>/`group-name`/`action-name``.

### gtk.ActionGroup.add_radio_actions

        def add_radio_actions(entries, value=0, on_change=None, user_data=None)

`entries` : | a list or tuple of radio action entry tuples
`value` : | the value of the radio action to set active
`on_change` : | a callback to connect to the "changed" signal of the first radio action
`user_data` : | data to pass to the `on_change` callback

### Note

This method is available in PyGTK 2.4 and above.

The `add_radio_actions`() method is a convenience method that creates a number of `gtk.RadioAction` objects based on the information in the list of action entry tuples contained in `entries` and adds them to the action group. The entry tuples can vary in size from one to six items with the following information:

- The name of the action. Must be specified.
- The stock id for the action. Optional with a default value of `None` if a label is specified.
- The label for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None` if a stock id is specified.
- The accelerator for the action, in the format understood by the `gtk.accelerator_parse`() function. Optional with a default value of `None`.
- The tooltip for the action. This field should typically be marked for translation, see the `set_translation_domain`() method. Optional with a default value of `None`.
- The value to set on the radio action. Optional with a default value of `0`. Should be specified in applications.

The `value` parameter specifies the radio action that should be set active. The "changed" signal of the first radio action is connected to the `on_change` callback (if specified and not `None`) and the accel paths of the actions are set to `<Actions>/`group-name`/`action-name``.

### gtk.ActionGroup.set_translation_domain

        def set_translation_domain(domain)

`domain` : | the translation domain to use for `dgettext()` calls

### Note

This method is available in PyGTK 2.4 and above.

The `set_translation_domain`() method sets the translation domain to the string specified by `domain` and uses `dgettext()` for translating the `label` and `tooltip` strings of the actions added by the `add_actions`(), `add_toggle_actions`() and `add_radio_actions`() methods.

### gtk.ActionGroup.translate_string

        def translate_string(string)

`string` : | the string to be translated
Returns : | the translation of `string`

### Note

This method is available in PyGTK 2.6 and above.

The `translate_string`() method translates the string specified by `string` using the specified `translate_func`(). This is mainly intended for language bindings.

## Signals

### The "connect-proxy" gtk.ActionGroup Signal

        def callback(actiongroup, action, proxy, user_param1, ...)

`actiongroup` : | the actiongroup that received the signal
`action` : | the action that is associated with `proxy`
`proxy` : | the proxy widget associated with `action`
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in PyGTK 2.4 and above.

The "connect-proxy" signal is emitted when the widget specified by `proxy` is connected to the `gtk.Action` specified by `action`.

### The "disconnect-proxy" gtk.ActionGroup Signal

        def callback(actiongroup, action, proxy, user_param1, ...)

`actiongroup` : | the actiongroup that received the signal
`action` : | the action that is associated with `proxy`
`proxy` : | the proxy widget associated with `action`
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in PyGTK 2.4 and above.

The "disconnect-proxy" signal is emitted when the widget specified by `proxy` is disconnected from the `gtk.Action` specified by `action`.

### The "post-activate" gtk.ActionGroup Signal

        def callback(actiongroup, action, user_param1, ...)

`actiongroup` : | the actiongroup that received the signal
`action` : | the action that is being activated
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in PyGTK 2.4 and above.

The "post-activate" signal is emitted after the `gtk.Action` specified by `action` has been activated.

### The "pre-activate" gtk.ActionGroup Signal

        def callback(actiongroup, action, user_param1, ...)

`actiongroup` : | the actiongroup that received the signal
`action` : | the action that is being activated
`user_param1` : | the first user parameter (if any) specified with the `connect`() method
`...` : | additional user parameters (if any)

### Note

This signal is available in PyGTK 2.4 and above.

The "pre-activate" signal is emitted before the `gtk.Action` specified by `action` is activated.

Prev | Up | Next
gtk.Action | Home | gtk.Activatable