# eric7.EricGui.EricAction

Module implementing an Action class extending QAction.

This extension is necessary in order to support alternate keyboard shortcuts.

### Global Attributes

None

### Classes

ArgumentsError | Class implementing an exception, which is raised, if the wrong number of arguments are given.
EricAction | Class implementing an Action class extending QAction.

### Functions

addActions | Module function to add a list of actions to a widget.
createActionGroup | Module function to create an action group.

## ArgumentsError

Class implementing an exception, which is raised, if the wrong number of arguments are given.

### Derived from

RuntimeError

### Class Attributes

None

### Class Methods

None

### Methods

ArgumentsError | Constructor
__repr__ | Special method returning a representation of the exception.
__str__ | Special method returning a string representation of the exception.

### Static Methods

None

#### ArgumentsError (Constructor)

ArgumentsError(error)

Constructor

error
  error message of the exception (string)

#### ArgumentsError.__repr__

__repr__()

Special method returning a representation of the exception.

Return:
  string representing the error message

#### ArgumentsError.__str__

__str__()

Special method returning a string representation of the exception.

Return:
  string representing the error message

Up

## EricAction

Class implementing an Action class extending QAction.

### Derived from

QAction

### Class Attributes

None

### Class Methods

None

### Methods

EricAction | Constructor
__ammendToolTip | Private slot to add the primary keyboard accelerator to the tooltip.
alternateShortcut | Public method to retrieve the alternative keyboard shortcut.
setAlternateShortcut | Public slot to set the alternative keyboard shortcut.
setIconText | Public slot to set the icon text of the action.
setShortcut | Public slot to set the keyboard shortcut.
setShortcuts | Public slot to set the list of keyboard shortcuts.

### Static Methods

None

#### EricAction (Constructor)

EricAction(*args)

Constructor

args
  argument list of the constructor. This list is one of
  - text (string), icon (QIcon), menu text (string), accelarator (QKeySequence), alternative accelerator (QKeySequence), parent (QObject), name (string), toggle (boolean)
  - text (string), icon (QIcon), menu text (string), accelarator (QKeySequence), alternative accelerator (QKeySequence), parent (QObject), name (string)
  - text (string), menu text (string), accelarator (QKeySequence), alternative accelerator (QKeySequence), parent (QObject), name (string), toggle (boolean)
  - text (string), menu text (string), accelarator (QKeySequence), alternative accelerator (QKeySequence), parent (QObject), name (string)

Raises ArgumentsError:
  raised to indicate invalid arguments

#### EricAction.__ammendToolTip

__ammendToolTip()

Private slot to add the primary keyboard accelerator to the tooltip.

#### EricAction.alternateShortcut

alternateShortcut()

Public method to retrieve the alternative keyboard shortcut.

Return:
  the alternative accelerator (QKeySequence)

#### EricAction.setAlternateShortcut

setAlternateShortcut(shortcut, removeEmpty=False)

Public slot to set the alternative keyboard shortcut.

shortcut
  the alternative accelerator (QKeySequence)
removeEmpty
  flag indicating to remove the alternate shortcut, if it is empty (boolean)

#### EricAction.setIconText

setIconText(text)

Public slot to set the icon text of the action.

text
  new icon text (string)

#### EricAction.setShortcut

setShortcut(shortcut)

Public slot to set the keyboard shortcut.

shortcut
  the accelerator (QKeySequence)

#### EricAction.setShortcuts

setShortcuts(shortcuts)

Public slot to set the list of keyboard shortcuts.

shortcuts
  list of keyboard accelerators (list of QKeySequence) or key for a platform dependent list of accelerators (QKeySequence.StandardKey)

Up

## addActions

addActions(target, actions)

Module function to add a list of actions to a widget.

target
  reference to the target widget (QWidget)
actions
  list of actions to be added to the target. A None indicates a separator (list of QActions)

Up

## createActionGroup

createActionGroup(parent, name=None, exclusive=False)

Module function to create an action group.

parent
  parent object of the action group (QObject)
name
  name of the action group object (string)
exclusive
  flag indicating an exclusive action group (boolean)

Return:
  reference to the created action group (QActionGroup)

Up