0
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2025-07-13 19:21:50 +02:00

feat: add clickable label util

This commit is contained in:
2025-06-03 08:56:51 +02:00
committed by David Perl
parent 594912136e
commit 2dda58f7d2
5 changed files with 26 additions and 4 deletions

View File

@ -0,0 +1,13 @@
from __future__ import annotations
from PySide6.QtGui import QMouseEvent
from qtpy.QtCore import Signal
from qtpy.QtWidgets import QLabel
class ClickableLabel(QLabel):
clicked = Signal()
def mouseReleaseEvent(self, ev: QMouseEvent) -> None:
self.clicked.emit()
return super().mouseReleaseEvent(ev)

View File

@ -14,6 +14,7 @@ from qtpy.QtWidgets import (
QWidget,
)
from bec_widgets.utils.clickable_label import ClickableLabel
from bec_widgets.utils.error_popups import SafeProperty, SafeSlot
@ -39,8 +40,8 @@ class ExpandableGroupFrame(QFrame):
self._title_layout = QHBoxLayout()
self._layout.addLayout(self._title_layout)
self._title = QLabel(f"<b>{title}</b>")
self._title_icon = QLabel()
self._title = ClickableLabel(f"<b>{title}</b>")
self._title_icon = ClickableLabel()
self._title_layout.addWidget(self._title_icon)
self._title_layout.addWidget(self._title)
self.icon_name = icon

View File

@ -2,7 +2,6 @@ import bec_qthemes
def pretty_display_theme(theme: str = "dark"):
print(f"loading theme {theme}")
palette = bec_qthemes.load_palette(theme)
foreground = palette.text().color().name()
background = palette.base().color().name()

View File

@ -65,6 +65,8 @@ class DeviceItem(ExpandableGroupFrame):
self.set_layout(layout)
self.adjustSize()
self._title.clicked.connect(self.switch_expanded_state)
self._title_icon.clicked.connect(self.switch_expanded_state)
@SafeSlot()
def switch_expanded_state(self):