spyder.api.widgets.status#

Status bar widgets API.

Classes

BaseTimerStatus([parent])

Base class for status bar widgets that update based on timers.

StatusBarWidget([parent, show_icon, ...])

Base class for status bar widgets.

class spyder.api.widgets.status.StatusBarWidget(
parent: QWidget | None = None,
show_icon: bool = True,
show_label: bool = True,
show_spinner: bool = False,
)[source]#

Bases: QWidget, SpyderWidgetMixin

Base class for status bar widgets.

These widgets consist by default of an icon, a label and a spinner, which are organized from left to right in that order.

You can also add any other QWidget to this layout by setting the CUSTOM_WIDGET_CLASS class attribute. It’ll be put between the label and the spinner.

ID: str | None = None#

Unique string identifier name for this widget.

CUSTOM_WIDGET_CLASS: type[QWidget] | None = None#

A custom widget class object to add to the default layout, or None to not add one.

INTERACT_ON_CLICK: bool = False#

If True, the user can interact with widget when clicking it (for example, to show a menu). If False, the default, the widget is not interactive.

sig_clicked: Signal#

Signal emitted when the widget is clicked.

__init__(
parent: QWidget | None = None,
show_icon: bool = True,
show_label: bool = True,
show_spinner: bool = False,
) None[source]#

Base class for status bar widgets.

These are composed of the following widgets, which are arranged in a QHBoxLayout from left to right:

  • Icon

  • Label

  • Custom QWidget

  • Spinner

Parameters:
  • parent (QWidget | None, optional) – The parent widget of this one, or None (default).

  • show_icon (bool, optional) – If True (default), show an icon in the widget. If False, don’t show an icon.

  • show_label (bool, optional) – If True (default), show a label in the widget. If False, don’t show a label.

  • show_spinner (bool, optional) – If True, show a progress spinner in the widget. If False (default), don’t show a spinner.

Notes

  • To use an icon, you need to redefine the get_icon() method.

  • To use a label, you need to call set_value().

get_icon() QIcon | None[source]#

Get the widget’s icon.

Returns:

The widget’s icon object, or None if it doesn’t have one.

Return type:

QIcon | None

set_icon() None[source]#

Set the icon for the status bar widget.

Return type:

None

set_value(value: str) None[source]#

Set formatted text value for the widget.

Parameters:

value (str) – The formatted text value to set.

Return type:

None

get_tooltip() str[source]#

Get the widget’s tooltip text.

Returns:

The widget’s tooltip text.

Return type:

str

update_tooltip() str[source]#

Update the tooltip for the widget.

Returns:

The updated tooltip text.

Return type:

str

mousePressEvent(event: QMouseEvent) None[source]#

Change the widget’s background color when it’s clicked.

Parameters:

event (QMouseEvent) – The mouse event that was triggered.

Return type:

None

mouseReleaseEvent(event: QMouseEvent) None[source]#

Change the widget’s background color & emit a signal when it’s clicked.

Parameters:

event (QMouseEvent) – The mouse release event.

Return type:

None

enterEvent(event: QEnterEvent) None[source]#

Change the widget’s background color and cursor shape on hover.

Parameters:

event (QEnterEvent) – The mouse hover event.

Return type:

None

leaveEvent(event: QEvent) None[source]#

Restore the widget’s background color when not hovering.

Parameters:

event (QEvent) – The mouse leave event.

Return type:

None

class spyder.api.widgets.status.BaseTimerStatus(parent: QWidget | None = None)[source]#

Bases: StatusBarWidget

Base class for status bar widgets that update based on timers.

__init__(parent: QWidget | None = None) None[source]#

Base class for status bar widgets that update based on timers.

Parameters:

parent (QWidget | None, optional) – The parent widget of this one, or None (default).

Return type:

None

closeEvent(event: QCloseEvent) None[source]#

Handle the widget close event by stopping the timer.

Parameters:

event (QCloseEvent) – The widget close event.

Return type:

None

setVisible(value: bool) None[source]#

Stop the timer if the widget is not visible.

Parameters:

value (bool) – True if the timer should be started, False to stop it.

Return type:

None

update_status() None[source]#

Update the status label widget, if the widget is visible.

Return type:

None

set_interval(interval: int) None[source]#

Set the timer interval.

Parameters:

interval (int) – The timer interval, in integer milliseconds.

Return type:

None

get_value() str[source]#

Return the formatted text value shown in the widget.

Returns:

The formatted text value.

Return type:

str

Raises:

NotImplementedError – Must be implemented by subclasses to work.