bec-widgets 0.109.1__py3-none-any.whl → 0.110.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- CHANGELOG.md +6 -8
- PKG-INFO +1 -1
- bec_widgets/qt_utils/palette_viewer.py +183 -0
- {bec_widgets-0.109.1.dist-info → bec_widgets-0.110.0.dist-info}/METADATA +1 -1
- {bec_widgets-0.109.1.dist-info → bec_widgets-0.110.0.dist-info}/RECORD +9 -8
- pyproject.toml +1 -1
- {bec_widgets-0.109.1.dist-info → bec_widgets-0.110.0.dist-info}/WHEEL +0 -0
- {bec_widgets-0.109.1.dist-info → bec_widgets-0.110.0.dist-info}/entry_points.txt +0 -0
- {bec_widgets-0.109.1.dist-info → bec_widgets-0.110.0.dist-info}/licenses/LICENSE +0 -0
CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## v0.110.0 (2024-09-12)
|
4
|
+
|
5
|
+
### Feature
|
6
|
+
|
7
|
+
* feat(palette_viewer): added widget to display the current palette and accent colors ([`a8576c1`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/a8576c164cad17746ec4fcd5c775fb78f70c055c))
|
8
|
+
|
3
9
|
## v0.109.1 (2024-09-09)
|
4
10
|
|
5
11
|
### Fix
|
@@ -155,11 +161,3 @@
|
|
155
161
|
* refactor: add docs, cleanup ([`61ecf49`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/61ecf491e52bfbfa0d5a84764a9095310659043d))
|
156
162
|
|
157
163
|
## v0.100.0 (2024-09-01)
|
158
|
-
|
159
|
-
### Documentation
|
160
|
-
|
161
|
-
* docs(becwidget): improvements to the bec widget base class docs; fixed type hint import for sphinx ([`99d5e8e`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/99d5e8e71c7f89a53d7967126f4056dde005534c))
|
162
|
-
|
163
|
-
### Fix
|
164
|
-
|
165
|
-
* fix(pyqt slot): removed slot decorator to avoid problems with pyqt6 ([`6c1f89a`](https://gitlab.psi.ch/bec/bec_widgets/-/commit/6c1f89ad39b7240ab1d1c1123422b99ae195bf01))
|
PKG-INFO
CHANGED
@@ -0,0 +1,183 @@
|
|
1
|
+
from qtpy.QtCore import Qt
|
2
|
+
from qtpy.QtWidgets import (
|
3
|
+
QApplication,
|
4
|
+
QFrame,
|
5
|
+
QGridLayout,
|
6
|
+
QHBoxLayout,
|
7
|
+
QLabel,
|
8
|
+
QScrollArea,
|
9
|
+
QSizePolicy,
|
10
|
+
QVBoxLayout,
|
11
|
+
QWidget,
|
12
|
+
)
|
13
|
+
|
14
|
+
from bec_widgets.utils.bec_widget import BECWidget
|
15
|
+
from bec_widgets.utils.colors import get_accent_colors, get_theme_palette
|
16
|
+
from bec_widgets.widgets.dark_mode_button.dark_mode_button import DarkModeButton
|
17
|
+
|
18
|
+
|
19
|
+
class PaletteViewer(BECWidget, QWidget):
|
20
|
+
"""
|
21
|
+
This class is a widget that displays current palette colors.
|
22
|
+
"""
|
23
|
+
|
24
|
+
ICON_NAME = "palette"
|
25
|
+
|
26
|
+
def __init__(self, *args, parent=None, **kwargs):
|
27
|
+
super().__init__(*args, theme_update=True, **kwargs)
|
28
|
+
QWidget.__init__(self, parent=parent)
|
29
|
+
self.setFixedSize(400, 600)
|
30
|
+
layout = QVBoxLayout(self)
|
31
|
+
dark_mode_button = DarkModeButton(self)
|
32
|
+
layout.addWidget(dark_mode_button)
|
33
|
+
|
34
|
+
# Create a scroll area to hold the color boxes
|
35
|
+
scroll_area = QScrollArea(self)
|
36
|
+
scroll_area.setWidgetResizable(True)
|
37
|
+
scroll_area.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
|
38
|
+
|
39
|
+
# Create a frame to hold the color boxes
|
40
|
+
self.frame = QFrame(self)
|
41
|
+
self.frame_layout = QGridLayout(self.frame)
|
42
|
+
self.frame_layout.setSpacing(0)
|
43
|
+
self.frame_layout.setContentsMargins(0, 0, 0, 0)
|
44
|
+
|
45
|
+
scroll_area.setWidget(self.frame)
|
46
|
+
layout.addWidget(scroll_area)
|
47
|
+
|
48
|
+
self.setLayout(layout)
|
49
|
+
|
50
|
+
self.update_palette()
|
51
|
+
|
52
|
+
def apply_theme(self, theme) -> None:
|
53
|
+
"""
|
54
|
+
Apply the theme to the widget.
|
55
|
+
|
56
|
+
Args:
|
57
|
+
theme (str): The theme to apply.
|
58
|
+
"""
|
59
|
+
self.update_palette()
|
60
|
+
|
61
|
+
def clear_palette(self) -> None:
|
62
|
+
"""
|
63
|
+
Clear the palette colors from the frame.
|
64
|
+
Recursively removes all widgets and layouts in the frame layout.
|
65
|
+
"""
|
66
|
+
# Iterate over all items in the layout in reverse to safely remove them
|
67
|
+
for i in reversed(range(self.frame_layout.count())):
|
68
|
+
item = self.frame_layout.itemAt(i)
|
69
|
+
|
70
|
+
# If the item is a layout, clear its contents
|
71
|
+
if isinstance(item, QHBoxLayout):
|
72
|
+
# Recursively remove all widgets from the layout
|
73
|
+
for j in reversed(range(item.count())):
|
74
|
+
widget = item.itemAt(j).widget()
|
75
|
+
if widget:
|
76
|
+
item.removeWidget(widget)
|
77
|
+
widget.deleteLater()
|
78
|
+
self.frame_layout.removeItem(item)
|
79
|
+
|
80
|
+
# If the item is a widget, remove and delete it
|
81
|
+
elif item.widget():
|
82
|
+
widget = item.widget()
|
83
|
+
self.frame_layout.removeWidget(widget)
|
84
|
+
widget.deleteLater()
|
85
|
+
|
86
|
+
def update_palette(self) -> None:
|
87
|
+
"""
|
88
|
+
Update the palette colors in the frame.
|
89
|
+
"""
|
90
|
+
self.clear_palette()
|
91
|
+
palette_label = QLabel("Palette Colors (e.g. palette.windowText().color())")
|
92
|
+
palette_label.setStyleSheet("font-weight: bold;")
|
93
|
+
self.frame_layout.addWidget(palette_label, 0, 0)
|
94
|
+
|
95
|
+
palette = get_theme_palette()
|
96
|
+
# Add the palette colors (roles) to the frame
|
97
|
+
palette_roles = [
|
98
|
+
palette.windowText,
|
99
|
+
palette.toolTipText,
|
100
|
+
palette.placeholderText,
|
101
|
+
palette.text,
|
102
|
+
palette.buttonText,
|
103
|
+
palette.highlight,
|
104
|
+
palette.link,
|
105
|
+
palette.light,
|
106
|
+
palette.midlight,
|
107
|
+
palette.mid,
|
108
|
+
palette.shadow,
|
109
|
+
palette.button,
|
110
|
+
palette.brightText,
|
111
|
+
palette.toolTipBase,
|
112
|
+
palette.alternateBase,
|
113
|
+
palette.dark,
|
114
|
+
palette.base,
|
115
|
+
palette.window,
|
116
|
+
palette.highlightedText,
|
117
|
+
palette.linkVisited,
|
118
|
+
]
|
119
|
+
|
120
|
+
offset = 1
|
121
|
+
for i, pal in enumerate(palette_roles):
|
122
|
+
i += offset
|
123
|
+
color = pal().color()
|
124
|
+
label_layout = QHBoxLayout()
|
125
|
+
color_label = QLabel(f"{pal().color().name()} ({pal.__name__})")
|
126
|
+
background_label = self.background_label_with_clipboard(color)
|
127
|
+
label_layout.addWidget(color_label)
|
128
|
+
label_layout.addWidget(background_label)
|
129
|
+
self.frame_layout.addLayout(label_layout, i, 0)
|
130
|
+
|
131
|
+
# add a horizontal spacer
|
132
|
+
spacer = QLabel()
|
133
|
+
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
|
134
|
+
self.frame_layout.addWidget(spacer, i + 1, 0)
|
135
|
+
|
136
|
+
accent_colors_label = QLabel("Accent Colors (e.g. accent_colors.default)")
|
137
|
+
accent_colors_label.setStyleSheet("font-weight: bold;")
|
138
|
+
self.frame_layout.addWidget(accent_colors_label, i + 2, 0)
|
139
|
+
|
140
|
+
accent_colors = get_accent_colors()
|
141
|
+
items = [
|
142
|
+
(accent_colors.default, "default"),
|
143
|
+
(accent_colors.success, "success"),
|
144
|
+
(accent_colors.warning, "warning"),
|
145
|
+
(accent_colors.emergency, "emergency"),
|
146
|
+
(accent_colors.highlight, "highlight"),
|
147
|
+
]
|
148
|
+
|
149
|
+
offset = len(palette_roles) + 2
|
150
|
+
for i, (color, name) in enumerate(items):
|
151
|
+
i += offset
|
152
|
+
label_layout = QHBoxLayout()
|
153
|
+
color_label = QLabel(f"{color.name()} ({name})")
|
154
|
+
background_label = self.background_label_with_clipboard(color)
|
155
|
+
label_layout.addWidget(color_label)
|
156
|
+
label_layout.addWidget(background_label)
|
157
|
+
self.frame_layout.addLayout(label_layout, i + 2, 0)
|
158
|
+
|
159
|
+
def background_label_with_clipboard(self, color) -> QLabel:
|
160
|
+
"""
|
161
|
+
Create a label with a background color that copies the color to the clipboard when clicked.
|
162
|
+
|
163
|
+
Args:
|
164
|
+
color (QColor): The color to display in the background.
|
165
|
+
|
166
|
+
Returns:
|
167
|
+
QLabel: The label with the background color.
|
168
|
+
"""
|
169
|
+
button = QLabel()
|
170
|
+
button.setStyleSheet(f"background-color: {color.name()};")
|
171
|
+
button.setToolTip("Click to copy color to clipboard")
|
172
|
+
button.setCursor(Qt.PointingHandCursor)
|
173
|
+
button.mousePressEvent = lambda event: QApplication.clipboard().setText(color.name())
|
174
|
+
return button
|
175
|
+
|
176
|
+
|
177
|
+
if __name__ == "__main__": # pragma: no cover
|
178
|
+
import sys
|
179
|
+
|
180
|
+
app = QApplication(sys.argv)
|
181
|
+
viewer = PaletteViewer()
|
182
|
+
viewer.show()
|
183
|
+
sys.exit(app.exec_())
|
@@ -2,11 +2,11 @@
|
|
2
2
|
.gitlab-ci.yml,sha256=Dc1iDjsc72UxdUtihx4uSZU0lrTQeR8hZwGx1MQBfKE,8432
|
3
3
|
.pylintrc,sha256=eeY8YwSI74oFfq6IYIbCqnx3Vk8ZncKaatv96n_Y8Rs,18544
|
4
4
|
.readthedocs.yaml,sha256=aSOc277LqXcsTI6lgvm_JY80lMlr69GbPKgivua2cS0,603
|
5
|
-
CHANGELOG.md,sha256=
|
5
|
+
CHANGELOG.md,sha256=nbKaG71Acd8pFUebpyIpOeqIlaGz5i4EB3EoNh_VWGQ,7088
|
6
6
|
LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
7
|
-
PKG-INFO,sha256=
|
7
|
+
PKG-INFO,sha256=PruUfU4YvPambSO4Kb_dKj-f9GIBjdy4UA8X7n7k3OM,1334
|
8
8
|
README.md,sha256=Od69x-RS85Hph0-WwWACwal4yUd67XkEn4APEfHhHFw,2649
|
9
|
-
pyproject.toml,sha256=
|
9
|
+
pyproject.toml,sha256=2g-vBp_QGwnPnWJID5EPdePgrVRX5-FEqWgGGHlu53M,2544
|
10
10
|
.git_hooks/pre-commit,sha256=n3RofIZHJl8zfJJIUomcMyYGFi_rwq4CC19z0snz3FI,286
|
11
11
|
.gitlab/issue_templates/bug_report_template.md,sha256=gAuyEwl7XlnebBrkiJ9AqffSNOywmr8vygUFWKTuQeI,386
|
12
12
|
.gitlab/issue_templates/documentation_update_template.md,sha256=FHLdb3TS_D9aL4CYZCjyXSulbaW5mrN2CmwTaeLPbNw,860
|
@@ -44,6 +44,7 @@ bec_widgets/examples/plugin_example_pyside/tictactoeplugin.py,sha256=MFMwONn4EZ3
|
|
44
44
|
bec_widgets/examples/plugin_example_pyside/tictactoetaskmenu.py,sha256=V6OVnBTS-60zjQ2FAs88Ldjm1MfoMROfiQZZu6Guav8,2379
|
45
45
|
bec_widgets/qt_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
46
46
|
bec_widgets/qt_utils/error_popups.py,sha256=y9gKKWaafp468ioHr96nBhf02ZpEgjDc-BAVOTWh-e8,7680
|
47
|
+
bec_widgets/qt_utils/palette_viewer.py,sha256=VpcYSYh__Bp5lgKmKbcFFWC0v5g7NELzHf73OEGY1So,6298
|
47
48
|
bec_widgets/qt_utils/redis_message_waiter.py,sha256=fvL_QgC0cTDv_FPJdRyp5AKjf401EJU4z3r38p47ydY,1745
|
48
49
|
bec_widgets/qt_utils/settings_dialog.py,sha256=NhtzTer_xzlB2lLLrGklkI1QYLJEWQpJoZbCz4o5daI,3645
|
49
50
|
bec_widgets/qt_utils/toolbar.py,sha256=QMXTbEFowVzbQzblXZVJcAhgd_zrqaqBISyd4QlPv1A,8576
|
@@ -255,8 +256,8 @@ bec_widgets/widgets/website/register_website_widget.py,sha256=LIQJpV9uqcBiPR9cEA
|
|
255
256
|
bec_widgets/widgets/website/website.py,sha256=42pncCc_zI2eqeMArIurVmPUukRo5bTxa2h1Skah-io,3012
|
256
257
|
bec_widgets/widgets/website/website_widget.pyproject,sha256=scOiV3cV1_BjbzpPzy2N8rIJL5P2qIZz8ObTJ-Uvdtg,25
|
257
258
|
bec_widgets/widgets/website/website_widget_plugin.py,sha256=pz38_C2cZ0yvPPS02wdIPcmhFo_yiwUhflsASocAPQQ,1341
|
258
|
-
bec_widgets-0.
|
259
|
-
bec_widgets-0.
|
260
|
-
bec_widgets-0.
|
261
|
-
bec_widgets-0.
|
262
|
-
bec_widgets-0.
|
259
|
+
bec_widgets-0.110.0.dist-info/METADATA,sha256=PruUfU4YvPambSO4Kb_dKj-f9GIBjdy4UA8X7n7k3OM,1334
|
260
|
+
bec_widgets-0.110.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
261
|
+
bec_widgets-0.110.0.dist-info/entry_points.txt,sha256=3otEkCdDB9LZJuBLzG4pFLK5Di0CVybN_12IsZrQ-58,166
|
262
|
+
bec_widgets-0.110.0.dist-info/licenses/LICENSE,sha256=YRKe85CBRyP7UpEAWwU8_qSIyuy5-l_9C-HKg5Qm8MQ,1511
|
263
|
+
bec_widgets-0.110.0.dist-info/RECORD,,
|
pyproject.toml
CHANGED
File without changes
|
File without changes
|
File without changes
|