From f4f92202c19dd9f5ba812110c157a97846f08aaf Mon Sep 17 00:00:00 2001 From: wyzula-jan Date: Tue, 2 Jul 2024 19:52:46 +0200 Subject: [PATCH] feat(color_button): patched ColorButton from pyqtgraph to be able to be opened in another QDialog --- bec_widgets/widgets/buttons/color_button.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bec_widgets/widgets/buttons/color_button.py diff --git a/bec_widgets/widgets/buttons/color_button.py b/bec_widgets/widgets/buttons/color_button.py new file mode 100644 index 00000000..0adb1d2b --- /dev/null +++ b/bec_widgets/widgets/buttons/color_button.py @@ -0,0 +1,17 @@ +import pyqtgraph as pg + + +class ColorButton(pg.ColorButton): + """ + A ColorButton that opens a dialog to select a color. Inherits from pyqtgraph.ColorButton. + Patches event loop of the ColorDialog, if opened in another QDialog. + """ + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + def selectColor(self): + self.origColor = self.color() + self.colorDialog.setCurrentColor(self.color()) + self.colorDialog.open() + self.colorDialog.exec()