iblqt.widgets.StatefulButton

class iblqt.widgets.StatefulButton[source]

Bases: QPushButton

A QPushButton that maintains an active/inactive state.

__init__(textActive=None, textInactive=None, active=False, parent=None)[source]

Initialize the StatefulButton with the specified active state.

Parameters:
  • textActive (str, optional) – The text shown on the button when in active state.

  • textInactive (str, optional) – The text shown on the button when in inactive state.

  • active (bool, optional) – Initial state of the button (default is False).

  • parent (QWidget) – The parent widget.

getActive()[source]

Get the active state of the button.

Returns:

True if the button is active, False otherwise.

Return type:

bool

getTextActive()[source]

Get the text shown on the button when in active state.

Returns:

The text shown during active state.

Return type:

str

getTextInactive()[source]

Get the text shown on the button during inactive state.

Returns:

The text shown during inactive state.

Return type:

str

setActive(value)[source]

Set the active state of the button.

Emits stateChanged if the state has changed.

Parameters:

value (bool) – The new active state of the button.

setTextActive(text)[source]

Set the text shown on the button when in active state.

Parameters:

text (str) – The text to be shown during active state.

setTextInactive(text)[source]

Set the text shown on the button during inactive state.

Parameters:

text (str) – The text to be shown during inactive state.

active: pyqtProperty

The active state of the button.

clickedWhileActive: Signal

Emitted when the button is clicked while it is in the active state.

clickedWhileInactive: Signal

Emitted when the button is clicked while it is in the inactive state.

stateChanged(bool): Signal

Emitted when the button’s state has changed. The signal carries the new state (True for active, False for inactive).

textActive

The text shown on the button during active state.

textInactive

The text shown on the button during inactive state.