Skip to content

common_widgets

common_widgets

Classes

ClickableHeaderWidget

Bases: QWidget

Widget emitting clicked when pressed with the left mouse button.

Attributes:

Name Type Description
clicked

emitted on left button press

Attributes
clicked = QtCore.Signal() class-attribute instance-attribute
Functions
mousePressEvent(mouse_event)

Emit clicked on left button press.

Parameters:

Name Type Description Default
mouse_event QMouseEvent

event.

required
Source code in src/nyx/editor/widgets/common_widgets.py
56
57
58
59
60
61
62
63
64
def mousePressEvent(self, mouse_event: QtGui.QMouseEvent) -> None:
    """Emit `clicked` on left button press.

    Args:
        mouse_event (QtGui.QMouseEvent): event.
    """
    if mouse_event.button() == QtCore.Qt.MouseButton.LeftButton:
        self.clicked.emit()
    super().mousePressEvent(mouse_event)

ElidedTextLabel(parent=None)

Bases: QLabel

QLabel that elides with '...' rather than forcing the window wider.

Initialize ElidedTextLabel.

Parameters:

Name Type Description Default
parent QWidget | None

parent widget.

None
Source code in src/nyx/editor/widgets/common_widgets.py
 7
 8
 9
10
11
12
13
14
15
16
17
def __init__(self, parent: QtWidgets.QWidget | None = None):
    """Initialize ElidedTextLabel.

    Args:
        parent (QtWidgets.QWidget | None): parent widget.
    """
    super().__init__(parent)
    self._full_text = ""
    self.setSizePolicy(
        QtWidgets.QSizePolicy.Policy.Ignored, QtWidgets.QSizePolicy.Policy.Preferred
    )
Functions
resizeEvent(resize_event)

Re-elide the text for the new width.

Parameters:

Name Type Description Default
resize_event QResizeEvent

event.

required
Source code in src/nyx/editor/widgets/common_widgets.py
29
30
31
32
33
34
35
36
def resizeEvent(self, resize_event) -> None:
    """Re-elide the text for the new width.

    Args:
        resize_event (QtGui.QResizeEvent): event.
    """
    super().resizeEvent(resize_event)
    self._refresh_elided_text()
set_full_text(full_text)

Set the text, elided to fit the width. The full text is the tooltip.

Parameters:

Name Type Description Default
full_text str

text to show.

required
Source code in src/nyx/editor/widgets/common_widgets.py
19
20
21
22
23
24
25
26
27
def set_full_text(self, full_text: str) -> None:
    """Set the text, elided to fit the width. The full text is the tooltip.

    Args:
        full_text (str): text to show.
    """
    self._full_text = full_text
    self.setToolTip(full_text)
    self._refresh_elided_text()