mirror of
https://github.com/bec-project/bec_widgets.git
synced 2025-07-14 03:31:50 +02:00
fix(color_button): signal and slot added for selecting color and for emitting color after change
This commit is contained in:
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from typing import Literal
|
||||
|
||||
import pyqtgraph as pg
|
||||
from qtpy.QtCore import Qt
|
||||
from qtpy.QtCore import Qt, Signal
|
||||
from qtpy.QtWidgets import QHBoxLayout, QWidget
|
||||
|
||||
from bec_widgets.qt_utils.error_popups import SafeSlot
|
||||
@ -15,6 +15,8 @@ class ColorButton(QWidget):
|
||||
Patches event loop of the ColorDialog, if opened in another QDialog.
|
||||
"""
|
||||
|
||||
color_selected = Signal(str)
|
||||
|
||||
ICON_NAME = "colors"
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -36,7 +38,9 @@ class ColorButton(QWidget):
|
||||
self.button.colorDialog.setCurrentColor(self.button.color())
|
||||
self.button.colorDialog.open()
|
||||
self.button.colorDialog.exec()
|
||||
self.color_selected.emit(self.button.color().name())
|
||||
|
||||
@SafeSlot(str)
|
||||
def set_color(self, color: tuple | str):
|
||||
"""
|
||||
Set the color of the button.
|
||||
|
Reference in New Issue
Block a user