# 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 (str)
  error message of the exception

#### ArgumentsError.__repr__

__repr__()

Special method returning a representation of the exception.

Return:
  string representing the error message

Return Type:
  str

#### ArgumentsError.__str__

__str__()

Special method returning a string representation of the exception.

Return:
  string representing the error message

Return Type:
  str

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 (list of one of the following)
  argument list of the constructor. This list is one of
  - text, icon, menu text, accelarator, alternative accelerator, parent, name, toggle
  - text, icon, menu text, accelarator, alternative accelerator, parent, name
  - text, menu text, accelarator, alternative accelerator, parent, name, toggle
  - text, menu text, accelarator, alternative accelerator, parent, name
  - str, QIcon, str, QKeySequence, QKeySequence, QObject, str, bool
  - str, QIcon, str, QKeySequence, QKeySequemce, QObject, str
  - str, str, QKeySequence, QKeySequence, QObject, str, bool
  - str, str, QKeySequence, QKeySequence, QObject, str

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

Return Type:
  QKeySequence

#### EricAction.setAlternateShortcut

setAlternateShortcut(shortcut, removeEmpty=False)

Public slot to set the alternative keyboard shortcut.

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

#### EricAction.setIconText

setIconText(text)

Public slot to set the icon text of the action.

text (str)
  new icon text

#### EricAction.setShortcut

setShortcut(shortcut)

Public slot to set the keyboard shortcut.

shortcut (QKeySequence)
  the accelerator

#### EricAction.setShortcuts

setShortcuts(shortcuts)

Public slot to set the list of keyboard shortcuts.

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

Up

## addActions

addActions(target, actions)

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

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

Up

## createActionGroup

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

Module function to create an action group.

parent (QObject)
  parent object of the action group
name (str)
  name of the action group object
exclusive (bool)
  flag indicating an exclusive action group

Return:
  reference to the created action group

Return Type:
  QActionGroup

Up