Action (hwx.gui)#

class Action(parent=None, name='', **kwds)#

Bases: object

GUI command used in Menus and ToolBars.

An action contains text, icons and a command callback. The action can be inserted into menus and/or toolbars. When the menu or toolbar button is clicked the action is called. Actions are used in Tool Wheel. The text displayed in the Tool Wheel is based on the text attribute which should be passed to tr() before.

Actions are modeled after Qts Action class. Refer to the Qt documentation for more information.

Attribute Table#

Name

Type

accel

property

checkable

property

checked

property

command

property

enabled

property

exclusive

property

icon

property

ison

property

name

property

selectable

property

statustip

property

text

property

tooltip

property

visible

property

whatsthis

property

Method Table#

Name

Description

destroy (self)

Deletes this and all its children.

get (name)

Returns the named action from defined in active profile.

onCommand (self)

Calls command callback method when an Action is clicked.

onToggle (self, on)

Acts when an Action is toggled.

toggle (self, on=None)

Simulate clicking the action.

onCommand()#

Calls command callback method when an Action is clicked.

onToggle(on)#

Acts when an Action is toggled.

  • If is coupled to dialog it will show or hide the dialog.

  • If is coupled to a context it will get in and out the context.

  • If is coupled to callback it will run the callback with state or not.

Parameters:

on (bool) – Determines whether to toggle on or off.

destroy()#

Deletes this and all its children.

Warning, make sure to remove the action from the ui before destroying or this will crash!

toggle(on=None)#

Simulate clicking the action.

Parameters:

on (bool | None) – Pass True/False to ensure you are toggling on or off. None flips the state.

property name#

Unique identifier across profiles.

This is only settable in the constructor.

property text#

Text label displayed in the menu/toolbar.

property icon#

File name of the icon.

  • Local names are looked up from the paths specified in addResourcePath.

  • When setting the icon the value can be a tuple of (icon, position) where position is the x,y translation of the icon.

property accel#

Key sequence to activate/toggle this action, like “Ctrl+q”.

property command#

Method called when the action button is clicked.

property visible: bool#

The visibility of the action.

Setting to False will visually remove this from the menu/toolbar.

property enabled#

The availability of the action.

Disabled actions are grayed out and the user cannot activate them.

property selectable#

The ability to select the action.

Setting to False allows for creating a background icon.

property exclusive#

The group exclusive property.

  • If this action is contained in a group and the group exclusive property is True, this action would toggle off when any other action in the group is toggled on.

  • Setting to False makes the actions toggle independently.

  • Setting to True simple does not do anything if the group is not set as exclusive.

property checkable: bool#

(bool) Does this action get toggled on and off?

property checked: bool#

(bool) Does the action appear toggled on?

Setting value does not emit signal (command is not called).

property ison: bool#

Determines if the action is on or not.

Deprecated: Use ‘checked’ property and ‘toggle’ method instead.

property tooltip#

Text displayed in a popup when cursor is over the icon or text.

property statustip#

Text displayed in the status bar when the cursor is over the icon or text.

property whatsthis#

Text displayed when cursor is over the icon or text and user hits F1.