algomancy-gui 0.3.16__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.
- algomancy_gui/__init__.py +0 -0
- algomancy_gui/admin_page/__init__.py +1 -0
- algomancy_gui/admin_page/admin.py +362 -0
- algomancy_gui/admin_page/sessions.py +57 -0
- algomancy_gui/appconfiguration.py +291 -0
- algomancy_gui/compare_page/__init__.py +1 -0
- algomancy_gui/compare_page/compare.py +360 -0
- algomancy_gui/compare_page/kpicard.py +236 -0
- algomancy_gui/compare_page/scenarioselector.py +99 -0
- algomancy_gui/componentids.py +177 -0
- algomancy_gui/contentregistry.py +167 -0
- algomancy_gui/cqmloader.py +58 -0
- algomancy_gui/data_page/__init__.py +1 -0
- algomancy_gui/data_page/data.py +77 -0
- algomancy_gui/data_page/datamanagementdeletemodal.py +260 -0
- algomancy_gui/data_page/datamanagementderivemodal.py +201 -0
- algomancy_gui/data_page/datamanagementdownloadmodal.py +193 -0
- algomancy_gui/data_page/datamanagementimportmodal.py +438 -0
- algomancy_gui/data_page/datamanagementsavemodal.py +191 -0
- algomancy_gui/data_page/datamanagementtopbar.py +123 -0
- algomancy_gui/data_page/datamanagementuploadmodal.py +366 -0
- algomancy_gui/data_page/dialogcallbacks.py +51 -0
- algomancy_gui/data_page/filenamematcher.py +109 -0
- algomancy_gui/defaultloader.py +36 -0
- algomancy_gui/gui_launcher.py +183 -0
- algomancy_gui/home_page/__init__.py +1 -0
- algomancy_gui/home_page/home.py +16 -0
- algomancy_gui/layout.py +199 -0
- algomancy_gui/layouthelpers.py +30 -0
- algomancy_gui/managergetters.py +28 -0
- algomancy_gui/overview_page/__init__.py +1 -0
- algomancy_gui/overview_page/overview.py +20 -0
- algomancy_gui/py.typed +0 -0
- algomancy_gui/scenario_page/__init__.py +0 -0
- algomancy_gui/scenario_page/delete_confirmation.py +29 -0
- algomancy_gui/scenario_page/new_scenario_creator.py +104 -0
- algomancy_gui/scenario_page/new_scenario_parameters_window.py +154 -0
- algomancy_gui/scenario_page/scenario_badge.py +36 -0
- algomancy_gui/scenario_page/scenario_cards.py +119 -0
- algomancy_gui/scenario_page/scenarios.py +596 -0
- algomancy_gui/sessionmanager.py +168 -0
- algomancy_gui/settingsmanager.py +43 -0
- algomancy_gui/stylingconfigurator.py +740 -0
- algomancy_gui-0.3.16.dist-info/METADATA +71 -0
- algomancy_gui-0.3.16.dist-info/RECORD +46 -0
- algomancy_gui-0.3.16.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,740 @@
|
|
|
1
|
+
from enum import StrEnum
|
|
2
|
+
from typing import Dict
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
class LayoutSelection(StrEnum):
|
|
6
|
+
SIDEBAR = "default"
|
|
7
|
+
TABBED = "tabbed"
|
|
8
|
+
FULLSCREEN = "fullscreen"
|
|
9
|
+
CUSTOM = "custom"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class CardHighlightMode(StrEnum):
|
|
13
|
+
LIGHT = "light"
|
|
14
|
+
DARK = "dark"
|
|
15
|
+
SUBTLE_LIGHT = "subtle-light"
|
|
16
|
+
SUBTLE_DARK = "subtle-dark"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ButtonColorMode(StrEnum):
|
|
20
|
+
UNIFIED = "unified"
|
|
21
|
+
SEPARATE = "separate"
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class ColorConfiguration:
|
|
25
|
+
def __init__(
|
|
26
|
+
self,
|
|
27
|
+
background_color: str = "#000000",
|
|
28
|
+
theme_color_primary: str = "#343a40",
|
|
29
|
+
theme_color_secondary: str = "#009688",
|
|
30
|
+
theme_color_tertiary: str = "#000000",
|
|
31
|
+
text_color: str = "#FFFFFF",
|
|
32
|
+
text_color_highlight: str = "#000000",
|
|
33
|
+
text_color_selected: str = "#FFFFFF",
|
|
34
|
+
menu_hover: str | None = None,
|
|
35
|
+
status_colors: dict[str, str] | None = None,
|
|
36
|
+
button_color_mode: ButtonColorMode = ButtonColorMode.SEPARATE,
|
|
37
|
+
button_text: str = "#FFFFFF",
|
|
38
|
+
button_colors: dict[str, str] | None = None,
|
|
39
|
+
):
|
|
40
|
+
self._background_color = background_color
|
|
41
|
+
self._theme_color_primary = theme_color_primary
|
|
42
|
+
self._theme_color_secondary = theme_color_secondary
|
|
43
|
+
self._theme_color_tertiary = theme_color_tertiary
|
|
44
|
+
self.text_color = text_color
|
|
45
|
+
self.text_color_highlight = text_color_highlight
|
|
46
|
+
self.text_color_selected = text_color_selected
|
|
47
|
+
self.menu_hover = menu_hover
|
|
48
|
+
self.status_colors = status_colors or {}
|
|
49
|
+
self._button_text = button_text
|
|
50
|
+
self.button_color_mode = button_color_mode
|
|
51
|
+
self.dm_colors = button_colors or {}
|
|
52
|
+
|
|
53
|
+
@staticmethod
|
|
54
|
+
def _hex_to_rgba(hex_str: str) -> tuple[int, ...]:
|
|
55
|
+
"""Convert hex color to RGBA tuple. If no alpha is provided, defaults to 255."""
|
|
56
|
+
h = hex_str.lstrip("#")
|
|
57
|
+
if len(h) == 6:
|
|
58
|
+
return tuple(int(h[i : i + 2], 16) for i in (0, 2, 4)) + (255,)
|
|
59
|
+
elif len(h) == 8:
|
|
60
|
+
return tuple(int(h[i : i + 2], 16) for i in (0, 2, 4, 6))
|
|
61
|
+
else:
|
|
62
|
+
raise ValueError("Invalid hex color format")
|
|
63
|
+
|
|
64
|
+
@staticmethod
|
|
65
|
+
def _rgba_to_hex(rgba: tuple[int, int, int, int]) -> str:
|
|
66
|
+
"""Convert RGBA tuple to hex string with an alpha channel."""
|
|
67
|
+
return "#%02x%02x%02x%02x" % rgba
|
|
68
|
+
|
|
69
|
+
@staticmethod
|
|
70
|
+
def reduce_color_opacity(color: str, opacity: float) -> str:
|
|
71
|
+
"""
|
|
72
|
+
Reduces the opacity of a color by setting its alpha channel.
|
|
73
|
+
|
|
74
|
+
Parameters:
|
|
75
|
+
color: str
|
|
76
|
+
The hexadecimal color value (e.g., "#RRGGBB" or "#RRGGBBAA").
|
|
77
|
+
opacity: float
|
|
78
|
+
The desired opacity level, must be between 0 and 1 inclusive, where
|
|
79
|
+
0 is fully transparent and 1 is fully opaque.
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
str
|
|
83
|
+
Hexadecimal representation with alpha channel (e.g., "#RRGGBBAA").
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
AssertionError
|
|
87
|
+
If the opacity parameter is not within the range [0, 1].
|
|
88
|
+
ValueError
|
|
89
|
+
If the color format is invalid.
|
|
90
|
+
"""
|
|
91
|
+
assert 0 <= opacity <= 1, "opacity must be between 0 and 1"
|
|
92
|
+
r, g, b, _ = ColorConfiguration._hex_to_rgba(color)
|
|
93
|
+
alpha = int(opacity * 255)
|
|
94
|
+
return ColorConfiguration._rgba_to_hex((r, g, b, alpha))
|
|
95
|
+
|
|
96
|
+
@staticmethod
|
|
97
|
+
def linear_combination_hex(a_hex: str, b_hex: str, t: float) -> str:
|
|
98
|
+
"""
|
|
99
|
+
Performs a linear combination of two hexadecimal color values based on a given ratio.
|
|
100
|
+
|
|
101
|
+
This static method calculates a blended color between two hex colors
|
|
102
|
+
using a provided ratio `t`. The calculation is performed by linearly
|
|
103
|
+
interpolating the red, green, and blue components separately.
|
|
104
|
+
|
|
105
|
+
Parameters:
|
|
106
|
+
a_hex: str
|
|
107
|
+
First hexadecimal color value in string format (e.g., "#RRGGBB").
|
|
108
|
+
b_hex: str
|
|
109
|
+
Second hexadecimal color value in string format (e.g., "#RRGGBB").
|
|
110
|
+
t: float
|
|
111
|
+
Blend ratio must be a value between 0 and 1 inclusive, where 0 corresponds
|
|
112
|
+
to the first color, and 1 corresponds to the second color.
|
|
113
|
+
|
|
114
|
+
Returns:
|
|
115
|
+
str
|
|
116
|
+
Hexadecimal representation of the blended color (e.g., "#RRGGBB").
|
|
117
|
+
|
|
118
|
+
Raises:
|
|
119
|
+
AssertionError
|
|
120
|
+
If the `t` parameter is not within the range [0, 1].
|
|
121
|
+
"""
|
|
122
|
+
assert 0 <= t <= 1, "t must be between 0 and 1"
|
|
123
|
+
ar, ag, ab, ao = ColorConfiguration._hex_to_rgba(a_hex)
|
|
124
|
+
br, bg, bb, bo = ColorConfiguration._hex_to_rgba(b_hex)
|
|
125
|
+
rr = int(ar + (br - ar) * t)
|
|
126
|
+
rg = int(ag + (bg - ag) * t)
|
|
127
|
+
rb = int(ab + (bb - ab) * t)
|
|
128
|
+
ro = int(ao + (bo - ao) * t)
|
|
129
|
+
return ColorConfiguration._rgba_to_hex((rr, rg, rb, ro))
|
|
130
|
+
|
|
131
|
+
def get_card_surface_shading(
|
|
132
|
+
self, card_highlight_mode: str = CardHighlightMode.SUBTLE_DARK
|
|
133
|
+
):
|
|
134
|
+
match card_highlight_mode:
|
|
135
|
+
case CardHighlightMode.SUBTLE_LIGHT:
|
|
136
|
+
return self.linear_combination_hex(
|
|
137
|
+
self._background_color, "#FFFFFF", 0.1
|
|
138
|
+
)
|
|
139
|
+
case CardHighlightMode.LIGHT:
|
|
140
|
+
return self.linear_combination_hex(
|
|
141
|
+
self._background_color, "#FFFFFF", 0.2
|
|
142
|
+
)
|
|
143
|
+
case CardHighlightMode.SUBTLE_DARK:
|
|
144
|
+
return self.linear_combination_hex(
|
|
145
|
+
self._background_color, "#000000", 0.1
|
|
146
|
+
)
|
|
147
|
+
case CardHighlightMode.DARK:
|
|
148
|
+
return self.linear_combination_hex(
|
|
149
|
+
self._background_color, "#000000", 0.2
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
raise ValueError(f"Invalid card highlight mode: {card_highlight_mode}")
|
|
153
|
+
|
|
154
|
+
def is_light_color(self, color: str) -> bool:
|
|
155
|
+
"""
|
|
156
|
+
Determines if a given hex color is light based on its RGB values.
|
|
157
|
+
|
|
158
|
+
A color is considered light if the sum of its RGB components is greater
|
|
159
|
+
than 384. This function takes a hex color code and checks its lightness.
|
|
160
|
+
|
|
161
|
+
Parameters:
|
|
162
|
+
color: str
|
|
163
|
+
A string representing a hex color code, such as "#FFFFFF" or "FFFFFF".
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
bool
|
|
167
|
+
True if the color is light, False otherwise.
|
|
168
|
+
"""
|
|
169
|
+
return (
|
|
170
|
+
self._hex_to_rgba(color)[0]
|
|
171
|
+
+ self._hex_to_rgba(color)[1]
|
|
172
|
+
+ self._hex_to_rgba(color)[2]
|
|
173
|
+
> 384
|
|
174
|
+
)
|
|
175
|
+
|
|
176
|
+
def default_hover_highlight(self, color: str) -> str:
|
|
177
|
+
"""
|
|
178
|
+
Generates a hover highlight color based on the input color's luminance.
|
|
179
|
+
|
|
180
|
+
If the input color is perceived as light, it blends the color with white;
|
|
181
|
+
otherwise, it blends the color with black. The blending factor used is 0.2.
|
|
182
|
+
|
|
183
|
+
Args:
|
|
184
|
+
color (str): A hexadecimal color string.
|
|
185
|
+
|
|
186
|
+
Returns:
|
|
187
|
+
str: A hexadecimal color string representing the hover highlight color.
|
|
188
|
+
"""
|
|
189
|
+
if self.is_light_color(color):
|
|
190
|
+
return self.linear_combination_hex(color, "#FFFFFF", 0.2)
|
|
191
|
+
else:
|
|
192
|
+
return self.linear_combination_hex(color, "#000000", 0.2)
|
|
193
|
+
|
|
194
|
+
@property
|
|
195
|
+
def menu_hover_color(self):
|
|
196
|
+
default = self.default_hover_highlight(self._theme_color_primary)
|
|
197
|
+
return self.menu_hover or default
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def status_processing(self):
|
|
201
|
+
default = self.linear_combination_hex(
|
|
202
|
+
self._theme_color_secondary, self._theme_color_primary, 0
|
|
203
|
+
)
|
|
204
|
+
return self.status_colors.get("processing", default)
|
|
205
|
+
|
|
206
|
+
@property
|
|
207
|
+
def status_queued(self):
|
|
208
|
+
default = self.linear_combination_hex(
|
|
209
|
+
self._theme_color_secondary, self._theme_color_primary, 0.25
|
|
210
|
+
)
|
|
211
|
+
return self.status_colors.get("queued", default)
|
|
212
|
+
|
|
213
|
+
@property
|
|
214
|
+
def status_completed(self):
|
|
215
|
+
default = self.linear_combination_hex(
|
|
216
|
+
self._theme_color_secondary, self._theme_color_primary, 0.5
|
|
217
|
+
)
|
|
218
|
+
return self.status_colors.get("completed", default)
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def status_failed(self):
|
|
222
|
+
default = self.linear_combination_hex(
|
|
223
|
+
self._theme_color_secondary, self._theme_color_primary, 0.75
|
|
224
|
+
)
|
|
225
|
+
return self.status_colors.get("failed", default)
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def status_created(self):
|
|
229
|
+
default = self.linear_combination_hex(
|
|
230
|
+
self._theme_color_secondary, self._theme_color_primary, 1
|
|
231
|
+
)
|
|
232
|
+
return self.status_colors.get("created", default)
|
|
233
|
+
|
|
234
|
+
def _get_button_color_with_default(self, tag, ratio):
|
|
235
|
+
"""
|
|
236
|
+
Determines and returns the appropriate color for a button based on the current button color
|
|
237
|
+
mode and provided parameters.
|
|
238
|
+
|
|
239
|
+
Parameters:
|
|
240
|
+
tag: str
|
|
241
|
+
The identifier for the button for which the color is being determined.
|
|
242
|
+
ratio: float
|
|
243
|
+
The weight used in calculating the combination of colors when the button color
|
|
244
|
+
mode is set to SEPARATE.
|
|
245
|
+
|
|
246
|
+
Raises:
|
|
247
|
+
ValueError:
|
|
248
|
+
If the button color mode is set to an invalid value.
|
|
249
|
+
|
|
250
|
+
Returns:
|
|
251
|
+
str: The hex color code of the determined button color.
|
|
252
|
+
"""
|
|
253
|
+
if self.button_color_mode == ButtonColorMode.SEPARATE:
|
|
254
|
+
default = self.linear_combination_hex(
|
|
255
|
+
self._theme_color_secondary, self._theme_color_primary, ratio
|
|
256
|
+
)
|
|
257
|
+
return self.dm_colors.get(tag, default)
|
|
258
|
+
elif self.button_color_mode == ButtonColorMode.UNIFIED:
|
|
259
|
+
default = self._theme_color_secondary
|
|
260
|
+
return self.dm_colors.get("unified_color", default)
|
|
261
|
+
else:
|
|
262
|
+
raise ValueError(f"Invalid button color mode: {self.button_color_mode}")
|
|
263
|
+
|
|
264
|
+
def _get_button_hover_color_with_default(self, color, tag):
|
|
265
|
+
"""
|
|
266
|
+
Retrieves the hover color for a button, with a default fallback mechanism.
|
|
267
|
+
|
|
268
|
+
This method determines the hover color for a button based on the current
|
|
269
|
+
button color mode. The hover color is derived from `tag` or a default
|
|
270
|
+
highlight fallback is returned when a specific hover color is not defined.
|
|
271
|
+
The method supports two button color modes: "SEPARATE" and "UNIFIED".
|
|
272
|
+
|
|
273
|
+
Parameters:
|
|
274
|
+
color: The base color used to calculate the default hover color.
|
|
275
|
+
tag: A string identifier used to determine the specific hover color.
|
|
276
|
+
|
|
277
|
+
Returns:
|
|
278
|
+
The hover color as defined in the button's design mode colors or the
|
|
279
|
+
default hover highlight color if the specific hover color is not found.
|
|
280
|
+
|
|
281
|
+
Raises:
|
|
282
|
+
ValueError: If the button color mode is not "SEPARATE" or "UNIFIED".
|
|
283
|
+
"""
|
|
284
|
+
if self.button_color_mode == ButtonColorMode.SEPARATE:
|
|
285
|
+
tag_st_mode = tag + "_hover"
|
|
286
|
+
elif self.button_color_mode == ButtonColorMode.UNIFIED:
|
|
287
|
+
tag_st_mode = "unified_hover"
|
|
288
|
+
else:
|
|
289
|
+
raise ValueError(f"Invalid button color mode: {self.button_color_mode}")
|
|
290
|
+
|
|
291
|
+
default = self.default_hover_highlight(color)
|
|
292
|
+
return self.dm_colors.get(tag_st_mode, default)
|
|
293
|
+
|
|
294
|
+
@property
|
|
295
|
+
def dm_derive(self):
|
|
296
|
+
return self._get_button_color_with_default("derive", 0)
|
|
297
|
+
|
|
298
|
+
@property
|
|
299
|
+
def dm_derive_hover(self):
|
|
300
|
+
return self._get_button_hover_color_with_default(self.dm_derive, "derive")
|
|
301
|
+
|
|
302
|
+
@property
|
|
303
|
+
def dm_delete(self):
|
|
304
|
+
return self._get_button_color_with_default("delete", 0.20)
|
|
305
|
+
|
|
306
|
+
@property
|
|
307
|
+
def dm_delete_hover(self):
|
|
308
|
+
return self._get_button_hover_color_with_default(self.dm_delete, "delete")
|
|
309
|
+
|
|
310
|
+
@property
|
|
311
|
+
def dm_save(self):
|
|
312
|
+
return self._get_button_color_with_default("save", 0.40)
|
|
313
|
+
|
|
314
|
+
@property
|
|
315
|
+
def dm_save_hover(self):
|
|
316
|
+
return self._get_button_hover_color_with_default(self.dm_save, "save")
|
|
317
|
+
|
|
318
|
+
@property
|
|
319
|
+
def dm_import(self):
|
|
320
|
+
return self._get_button_color_with_default("import", 0.60)
|
|
321
|
+
|
|
322
|
+
@property
|
|
323
|
+
def dm_import_hover(self):
|
|
324
|
+
return self._get_button_hover_color_with_default(self.dm_import, "import")
|
|
325
|
+
|
|
326
|
+
@property
|
|
327
|
+
def dm_upload(self):
|
|
328
|
+
return self._get_button_color_with_default("upload", 0.80)
|
|
329
|
+
|
|
330
|
+
@property
|
|
331
|
+
def dm_upload_hover(self):
|
|
332
|
+
return self._get_button_hover_color_with_default(self.dm_upload, "upload")
|
|
333
|
+
|
|
334
|
+
@property
|
|
335
|
+
def dm_download(self):
|
|
336
|
+
return self._get_button_color_with_default("download", 1)
|
|
337
|
+
|
|
338
|
+
@property
|
|
339
|
+
def dm_download_hover(self):
|
|
340
|
+
return self._get_button_hover_color_with_default(self.dm_download, "download")
|
|
341
|
+
|
|
342
|
+
# Modal colors for derive
|
|
343
|
+
@property
|
|
344
|
+
def derive_confirm(self):
|
|
345
|
+
return self.dm_derive
|
|
346
|
+
|
|
347
|
+
@property
|
|
348
|
+
def derive_confirm_hover(self):
|
|
349
|
+
return self.dm_derive_hover
|
|
350
|
+
|
|
351
|
+
@property
|
|
352
|
+
def derive_cancel(self):
|
|
353
|
+
return self._get_button_color_with_default("derive_cancel", 0.20)
|
|
354
|
+
|
|
355
|
+
@property
|
|
356
|
+
def derive_cancel_hover(self):
|
|
357
|
+
return self._get_button_hover_color_with_default(
|
|
358
|
+
self.derive_cancel, "derive_cancel"
|
|
359
|
+
)
|
|
360
|
+
|
|
361
|
+
# Modal colors for delete
|
|
362
|
+
@property
|
|
363
|
+
def delete_confirm(self):
|
|
364
|
+
return self.dm_delete
|
|
365
|
+
|
|
366
|
+
@property
|
|
367
|
+
def delete_confirm_hover(self):
|
|
368
|
+
return self.dm_delete_hover
|
|
369
|
+
|
|
370
|
+
@property
|
|
371
|
+
def delete_cancel(self):
|
|
372
|
+
return self._get_button_color_with_default("delete_cancel", 0.20)
|
|
373
|
+
|
|
374
|
+
@property
|
|
375
|
+
def delete_cancel_hover(self):
|
|
376
|
+
return self._get_button_hover_color_with_default(
|
|
377
|
+
self.delete_cancel, "delete_cancel"
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
# Modal colors for save
|
|
381
|
+
@property
|
|
382
|
+
def save_confirm(self):
|
|
383
|
+
return self.dm_save
|
|
384
|
+
|
|
385
|
+
@property
|
|
386
|
+
def save_confirm_hover(self):
|
|
387
|
+
return self.dm_save_hover
|
|
388
|
+
|
|
389
|
+
@property
|
|
390
|
+
def save_cancel(self):
|
|
391
|
+
return self._get_button_color_with_default("save_cancel", 0.20)
|
|
392
|
+
|
|
393
|
+
@property
|
|
394
|
+
def save_cancel_hover(self):
|
|
395
|
+
return self._get_button_hover_color_with_default(
|
|
396
|
+
self.save_cancel, "save_cancel"
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
# Modal colors for import
|
|
400
|
+
@property
|
|
401
|
+
def import_confirm(self):
|
|
402
|
+
return self.dm_import
|
|
403
|
+
|
|
404
|
+
@property
|
|
405
|
+
def import_confirm_hover(self):
|
|
406
|
+
return self.dm_import_hover
|
|
407
|
+
|
|
408
|
+
@property
|
|
409
|
+
def import_cancel(self):
|
|
410
|
+
return self._get_button_color_with_default("import_cancel", 0.20)
|
|
411
|
+
|
|
412
|
+
@property
|
|
413
|
+
def import_cancel_hover(self):
|
|
414
|
+
return self._get_button_hover_color_with_default(
|
|
415
|
+
self.import_cancel, "import_cancel"
|
|
416
|
+
)
|
|
417
|
+
|
|
418
|
+
# Modal colors for upload
|
|
419
|
+
@property
|
|
420
|
+
def upload_confirm(self):
|
|
421
|
+
return self.dm_upload
|
|
422
|
+
|
|
423
|
+
@property
|
|
424
|
+
def upload_confirm_hover(self):
|
|
425
|
+
return self.dm_upload_hover
|
|
426
|
+
|
|
427
|
+
@property
|
|
428
|
+
def upload_cancel(self):
|
|
429
|
+
return self._get_button_color_with_default("upload_cancel", 0.20)
|
|
430
|
+
|
|
431
|
+
@property
|
|
432
|
+
def upload_cancel_hover(self):
|
|
433
|
+
return self._get_button_hover_color_with_default(
|
|
434
|
+
self.upload_cancel, "upload_cancel"
|
|
435
|
+
)
|
|
436
|
+
|
|
437
|
+
# Modal colors for download
|
|
438
|
+
@property
|
|
439
|
+
def download_confirm(self):
|
|
440
|
+
return self.dm_download
|
|
441
|
+
|
|
442
|
+
@property
|
|
443
|
+
def download_confirm_hover(self):
|
|
444
|
+
return self.dm_download_hover
|
|
445
|
+
|
|
446
|
+
@property
|
|
447
|
+
def download_cancel(self):
|
|
448
|
+
return self._get_button_color_with_default("download_cancel", 0.20)
|
|
449
|
+
|
|
450
|
+
@property
|
|
451
|
+
def download_cancel_hover(self):
|
|
452
|
+
return self._get_button_hover_color_with_default(
|
|
453
|
+
self.download_cancel, "download_cancel"
|
|
454
|
+
)
|
|
455
|
+
|
|
456
|
+
# Scenario actions
|
|
457
|
+
@property
|
|
458
|
+
def new_scenario(self):
|
|
459
|
+
return self._get_button_color_with_default("new_scenario", 0.40)
|
|
460
|
+
|
|
461
|
+
@property
|
|
462
|
+
def new_scenario_hover(self):
|
|
463
|
+
return self._get_button_hover_color_with_default(
|
|
464
|
+
self.new_scenario, "new_scenario"
|
|
465
|
+
)
|
|
466
|
+
|
|
467
|
+
@property
|
|
468
|
+
def new_scenario_confirm(self):
|
|
469
|
+
return self.new_scenario
|
|
470
|
+
|
|
471
|
+
@property
|
|
472
|
+
def new_scenario_confirm_hover(self):
|
|
473
|
+
return self.new_scenario_hover
|
|
474
|
+
|
|
475
|
+
@property
|
|
476
|
+
def new_scenario_cancel(self):
|
|
477
|
+
return self._get_button_color_with_default("new_scenario_cancel", 0.20)
|
|
478
|
+
|
|
479
|
+
@property
|
|
480
|
+
def new_scenario_cancel_hover(self):
|
|
481
|
+
return self._get_button_hover_color_with_default(
|
|
482
|
+
self.new_scenario_cancel, "new_scenario_cancel"
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
# Compare toggle
|
|
486
|
+
@property
|
|
487
|
+
def compare_toggle(self):
|
|
488
|
+
return self._get_button_color_with_default("compare", 1)
|
|
489
|
+
|
|
490
|
+
@staticmethod
|
|
491
|
+
def _get_handle_url(color):
|
|
492
|
+
color_no_hex = color.lstrip("#")
|
|
493
|
+
return (
|
|
494
|
+
(
|
|
495
|
+
f"url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' "
|
|
496
|
+
f"viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23{color_no_hex}'/%3e%3c/svg%3e\")"
|
|
497
|
+
),
|
|
498
|
+
)
|
|
499
|
+
|
|
500
|
+
@property
|
|
501
|
+
def compare_active_handle_url(self):
|
|
502
|
+
return self._get_handle_url(self.text_color_selected)
|
|
503
|
+
|
|
504
|
+
@property
|
|
505
|
+
def compare_inactive_handle_url(self):
|
|
506
|
+
return self._get_handle_url(self.text_color)
|
|
507
|
+
|
|
508
|
+
@property
|
|
509
|
+
def compare_focussed_handle_url(self):
|
|
510
|
+
shadow_color = self.reduce_color_opacity(self._theme_color_primary, 0.3)
|
|
511
|
+
return self._get_handle_url(shadow_color)
|
|
512
|
+
|
|
513
|
+
@property
|
|
514
|
+
def toggle_background_color(self):
|
|
515
|
+
return self.get_card_surface_shading()
|
|
516
|
+
|
|
517
|
+
@property
|
|
518
|
+
def toggle_shadow_color(self):
|
|
519
|
+
return self.reduce_color_opacity(self.toggle_active_color, 0.3)
|
|
520
|
+
|
|
521
|
+
@property
|
|
522
|
+
def toggle_active_color(self):
|
|
523
|
+
return self._get_button_color_with_default("standard", 1)
|
|
524
|
+
|
|
525
|
+
@property
|
|
526
|
+
def toggle_handle_selected(self):
|
|
527
|
+
return self._get_handle_url(self.text_color_selected)
|
|
528
|
+
|
|
529
|
+
@property
|
|
530
|
+
def toggle_handle_focussed(self):
|
|
531
|
+
return self._get_handle_url(self.toggle_shadow_color)
|
|
532
|
+
|
|
533
|
+
@property
|
|
534
|
+
def toggle_handle_inactive(self):
|
|
535
|
+
return self._get_handle_url(self.text_color)
|
|
536
|
+
|
|
537
|
+
@staticmethod
|
|
538
|
+
def dm_bootstrap_defaults() -> Dict[str, str]:
|
|
539
|
+
return {
|
|
540
|
+
"derive": "primary",
|
|
541
|
+
"delete": "danger",
|
|
542
|
+
"upload": "secondary",
|
|
543
|
+
"save": "success",
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
def get_theme_colors(
|
|
547
|
+
self, card_highlight_mode: str = CardHighlightMode.SUBTLE_LIGHT
|
|
548
|
+
):
|
|
549
|
+
main_colors = {
|
|
550
|
+
"--background-color": self._background_color,
|
|
551
|
+
"--theme-primary": self._theme_color_primary,
|
|
552
|
+
"--theme-secondary": self._theme_color_secondary,
|
|
553
|
+
"--theme-tertiary": self._theme_color_tertiary,
|
|
554
|
+
"--text-color": self.text_color,
|
|
555
|
+
"--text-selected": self.text_color_selected,
|
|
556
|
+
"--text-highlight": self.text_color_highlight,
|
|
557
|
+
"--card-surface": self.get_card_surface_shading(card_highlight_mode),
|
|
558
|
+
"--button-text": self._button_text,
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
data_management_colors = {
|
|
562
|
+
"--status-processing": self.status_processing,
|
|
563
|
+
"--status-queued": self.status_queued,
|
|
564
|
+
"--status-completed": self.status_completed,
|
|
565
|
+
"--status-failed": self.status_failed,
|
|
566
|
+
"--status-created": self.status_created,
|
|
567
|
+
"--derive-color": self.dm_derive,
|
|
568
|
+
"--derive-color-hover": self.dm_derive_hover,
|
|
569
|
+
"--delete-color": self.dm_delete,
|
|
570
|
+
"--delete-color-hover": self.dm_delete_hover,
|
|
571
|
+
"--save-color": self.dm_save,
|
|
572
|
+
"--save-color-hover": self.dm_save_hover,
|
|
573
|
+
"--import-color": self.dm_import,
|
|
574
|
+
"--import-color-hover": self.dm_import_hover,
|
|
575
|
+
"--upload-color": self.dm_upload,
|
|
576
|
+
"--upload-color-hover": self.dm_upload_hover,
|
|
577
|
+
"--download-color": self.dm_download,
|
|
578
|
+
"--download-color-hover": self.dm_download_hover,
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
data_modal_colors = {
|
|
582
|
+
"--derive-modal-confirm-color": self.derive_confirm,
|
|
583
|
+
"--derive-modal-confirm-color-hover": self.derive_confirm_hover,
|
|
584
|
+
"--derive-modal-cancel-color": self.derive_cancel,
|
|
585
|
+
"--derive-modal-cancel-color-hover": self.derive_cancel_hover,
|
|
586
|
+
"--delete-modal-confirm-color": self.delete_confirm,
|
|
587
|
+
"--delete-modal-confirm-color-hover": self.delete_confirm_hover,
|
|
588
|
+
"--delete-modal-cancel-color": self.delete_cancel,
|
|
589
|
+
"--delete-modal-cancel-color-hover": self.delete_cancel_hover,
|
|
590
|
+
"--save-modal-confirm-color": self.save_confirm,
|
|
591
|
+
"--save-modal-confirm-color-hover": self.save_confirm_hover,
|
|
592
|
+
"--save-modal-cancel-color": self.save_cancel,
|
|
593
|
+
"--save-modal-cancel-color-hover": self.save_cancel_hover,
|
|
594
|
+
"--import-modal-confirm-color": self.import_confirm,
|
|
595
|
+
"--import-modal-confirm-color-hover": self.import_confirm_hover,
|
|
596
|
+
"--import-modal-cancel-color": self.import_cancel,
|
|
597
|
+
"--import-modal-cancel-color-hover": self.import_cancel_hover,
|
|
598
|
+
"--upload-modal-confirm-color": self.upload_confirm,
|
|
599
|
+
"--upload-modal-confirm-color-hover": self.upload_confirm_hover,
|
|
600
|
+
"--upload-modal-cancel-color": self.upload_cancel,
|
|
601
|
+
"--upload-modal-cancel-color-hover": self.upload_cancel_hover,
|
|
602
|
+
"--download-modal-confirm-color": self.download_confirm,
|
|
603
|
+
"--download-modal-confirm-color-hover": self.download_confirm_hover,
|
|
604
|
+
"--download-modal-cancel-color": self.download_cancel,
|
|
605
|
+
"--download-modal-cancel-color-hover": self.download_cancel_hover,
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
scenarios_colors = {
|
|
609
|
+
"--new-scenario-color": self.new_scenario,
|
|
610
|
+
"--new-scenario-color-hover": self.new_scenario_hover,
|
|
611
|
+
"--new-scenario-modal-confirm-color": self.new_scenario_confirm,
|
|
612
|
+
"--new-scenario-modal-confirm-color-hover": self.new_scenario_confirm_hover,
|
|
613
|
+
"--new-scenario-modal-cancel-color": self.new_scenario_cancel,
|
|
614
|
+
"--new-scenario-modal-cancel-color-hover": self.new_scenario_cancel_hover,
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
compare_colors = {
|
|
618
|
+
"--compare-toggle-color": self.compare_toggle,
|
|
619
|
+
"--compare-active-handle-url": self.compare_active_handle_url,
|
|
620
|
+
"--compare-inactive-handle-url": self.compare_inactive_handle_url,
|
|
621
|
+
"--compare-focussed-handle-url": self.compare_focussed_handle_url,
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
toggle_colors = {
|
|
625
|
+
"--toggle-background-color": self.toggle_background_color,
|
|
626
|
+
"--toggle-shadow-color": self.toggle_shadow_color,
|
|
627
|
+
"--toggle-active-color": self.toggle_active_color,
|
|
628
|
+
"--toggle-handle-selected": self.toggle_handle_selected,
|
|
629
|
+
"--toggle-handle-focussed": self.toggle_handle_focussed,
|
|
630
|
+
"--toggle-handle-inactive": self.toggle_handle_inactive,
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
all_colors = {
|
|
634
|
+
**main_colors,
|
|
635
|
+
**data_management_colors,
|
|
636
|
+
**data_modal_colors,
|
|
637
|
+
**scenarios_colors,
|
|
638
|
+
**compare_colors,
|
|
639
|
+
**toggle_colors,
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
return all_colors
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
class StylingConfigurator:
|
|
646
|
+
"""
|
|
647
|
+
Manages the configuration and customization of application styling.
|
|
648
|
+
|
|
649
|
+
The StylingConfigurator class provides a mechanism to configure various UI
|
|
650
|
+
styling options such as layout, colors, logos, and button visuals. It allows
|
|
651
|
+
for the definition of consistent styling themes and reusable configurations
|
|
652
|
+
for an application.
|
|
653
|
+
|
|
654
|
+
Note: construction arguments "logo_path" and "button_path" should be provided
|
|
655
|
+
as a path string, as if the current root is the assets folder.
|
|
656
|
+
|
|
657
|
+
Attributes:
|
|
658
|
+
layout_selection (LayoutSelection): Defines the layout selection for the
|
|
659
|
+
application interface (e.g., sidebar layout).
|
|
660
|
+
color_configuration (ColorConfiguration): Manages the colors for different
|
|
661
|
+
UI components such as background, text, and highlights.
|
|
662
|
+
logo_url (str): Path or URL to the logo image file to be used in the UI.
|
|
663
|
+
button_url (str): Path or URL to the button image file to be used in the UI.
|
|
664
|
+
card_highlight_mode (str): Specifies the mode for highlighting cards in
|
|
665
|
+
the UI, affecting the appearance of card components.
|
|
666
|
+
"""
|
|
667
|
+
|
|
668
|
+
def __init__(
|
|
669
|
+
self,
|
|
670
|
+
layout_selection: LayoutSelection = LayoutSelection.SIDEBAR,
|
|
671
|
+
color_configuration: ColorConfiguration = ColorConfiguration(),
|
|
672
|
+
logo_path: str = None,
|
|
673
|
+
button_path: str = None,
|
|
674
|
+
card_highlight_mode: str = CardHighlightMode.SUBTLE_LIGHT,
|
|
675
|
+
):
|
|
676
|
+
self.layout_selection = layout_selection
|
|
677
|
+
self.color_configuration = color_configuration
|
|
678
|
+
self.logo_url = "assets/" + logo_path if logo_path else ""
|
|
679
|
+
self.button_url = "assets/" + button_path if button_path else ""
|
|
680
|
+
self.card_highlight_mode = card_highlight_mode
|
|
681
|
+
|
|
682
|
+
@property
|
|
683
|
+
def card_surface_shading(self):
|
|
684
|
+
return self.color_configuration.get_card_surface_shading(
|
|
685
|
+
self.card_highlight_mode
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
def initiate_theme_colors(self):
|
|
689
|
+
return self.color_configuration.get_theme_colors(self.card_highlight_mode)
|
|
690
|
+
|
|
691
|
+
@staticmethod
|
|
692
|
+
def get_cqm_config() -> "StylingConfigurator":
|
|
693
|
+
return StylingConfigurator(
|
|
694
|
+
layout_selection=LayoutSelection.SIDEBAR,
|
|
695
|
+
color_configuration=ColorConfiguration(
|
|
696
|
+
background_color="#e3f8ff",
|
|
697
|
+
theme_color_primary="#4C0265",
|
|
698
|
+
theme_color_secondary="#3EBDF3",
|
|
699
|
+
text_color="#424242",
|
|
700
|
+
text_color_highlight="#EF7B13",
|
|
701
|
+
text_color_selected="#e3f8ff",
|
|
702
|
+
),
|
|
703
|
+
logo_path="cqm-logo-white.png",
|
|
704
|
+
button_path="cqm-button-white.png",
|
|
705
|
+
card_highlight_mode=CardHighlightMode.LIGHT,
|
|
706
|
+
)
|
|
707
|
+
|
|
708
|
+
@staticmethod
|
|
709
|
+
def get_blue_config() -> "StylingConfigurator":
|
|
710
|
+
return StylingConfigurator(
|
|
711
|
+
layout_selection=LayoutSelection.SIDEBAR,
|
|
712
|
+
color_configuration=ColorConfiguration(
|
|
713
|
+
background_color="#FFFFFF",
|
|
714
|
+
theme_color_primary="#3366CA",
|
|
715
|
+
theme_color_secondary="#000000",
|
|
716
|
+
text_color="#3366CA",
|
|
717
|
+
text_color_highlight="#FFFFFF",
|
|
718
|
+
text_color_selected="#FFFFFF",
|
|
719
|
+
),
|
|
720
|
+
logo_path="cqm-logo-white.png",
|
|
721
|
+
button_path="cqm-button-white.png",
|
|
722
|
+
card_highlight_mode=CardHighlightMode.SUBTLE_DARK,
|
|
723
|
+
)
|
|
724
|
+
|
|
725
|
+
@staticmethod
|
|
726
|
+
def get_red_config() -> "StylingConfigurator":
|
|
727
|
+
return StylingConfigurator(
|
|
728
|
+
layout_selection=LayoutSelection.SIDEBAR,
|
|
729
|
+
color_configuration=ColorConfiguration(
|
|
730
|
+
background_color="#E4EEF1",
|
|
731
|
+
theme_color_primary="#982649",
|
|
732
|
+
theme_color_secondary="#FFB86F",
|
|
733
|
+
text_color="#131B23",
|
|
734
|
+
text_color_highlight="#000000",
|
|
735
|
+
text_color_selected="#FFFFFF",
|
|
736
|
+
),
|
|
737
|
+
logo_path="cqm-logo-white.png",
|
|
738
|
+
button_path="cqm-button-white.png",
|
|
739
|
+
card_highlight_mode=CardHighlightMode.SUBTLE_DARK,
|
|
740
|
+
)
|