gui-utilities 1.3.9__py3-none-any.whl → 1.3.48__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.
Potentially problematic release.
This version of gui-utilities might be problematic. Click here for more details.
- gui_utilities/gui_utilities.py +267 -64
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.48.dist-info}/METADATA +1 -1
- gui_utilities-1.3.48.dist-info/RECORD +11 -0
- gui_utilities-1.3.9.dist-info/RECORD +0 -11
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.48.dist-info}/WHEEL +0 -0
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.48.dist-info}/licenses/LICENSE +0 -0
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.48.dist-info}/top_level.txt +0 -0
gui_utilities/gui_utilities.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from PyQt6.QtCore import Qt, QObject, QEvent, QSize
|
|
2
|
-
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QComboBox, QDialog, QToolButton, QWidgetAction, QCheckBox, QTableWidget, QHeaderView
|
|
3
|
-
from PyQt6.QtGui import QIcon,
|
|
2
|
+
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QComboBox, QDialog, QToolButton, QWidgetAction, QCheckBox, QTableWidget, QHeaderView, QApplication, QStyle, QStyledItemDelegate
|
|
3
|
+
from PyQt6.QtGui import QIcon, QTextDocument
|
|
4
4
|
import re
|
|
5
5
|
import requests
|
|
6
6
|
import importlib.resources
|
|
@@ -9,8 +9,18 @@ main_dir = importlib.resources.files("gui_utilities")
|
|
|
9
9
|
icons_dir = main_dir / "icons"
|
|
10
10
|
tlds_path = main_dir / "tlds"
|
|
11
11
|
|
|
12
|
-
def
|
|
13
|
-
|
|
12
|
+
def latex_to_html(expression):
|
|
13
|
+
html_expression = expression
|
|
14
|
+
html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
|
|
15
|
+
html_expression = re.sub(r"_\{([^}]+)\}", r"<sub>\1</sub>", html_expression)
|
|
16
|
+
html_expression = re.sub(r"\^\{([^}]+)\}", r"<sup>\1</sup>", html_expression)
|
|
17
|
+
html_expression = re.sub(r"_([a-zA-Z0-9]+)", r"<sub>\1</sub>", html_expression)
|
|
18
|
+
html_expression = re.sub(r"\^([a-zA-Z0-9]+)", r"<sup>\1</sup>", html_expression)
|
|
19
|
+
html_expression = html_expression.replace(" ", " ")
|
|
20
|
+
return html_expression
|
|
21
|
+
|
|
22
|
+
def create_window(title, background_color = "#1e1e1e", parent = None):
|
|
23
|
+
window = QWidget(parent)
|
|
14
24
|
window.setObjectName("window")
|
|
15
25
|
window.setWindowTitle(title)
|
|
16
26
|
window.setStyleSheet(f"#window {{background-color: {background_color};}}")
|
|
@@ -18,7 +28,7 @@ def create_window(title, background_color = "#1e1e1e"):
|
|
|
18
28
|
window.setLayout(main_layout)
|
|
19
29
|
return window
|
|
20
30
|
|
|
21
|
-
def
|
|
31
|
+
def create_menu(
|
|
22
32
|
ui_instance,
|
|
23
33
|
buttons,
|
|
24
34
|
title,
|
|
@@ -33,7 +43,9 @@ def create_form(
|
|
|
33
43
|
title_padding_bottom = None,
|
|
34
44
|
title_border_width = 0,
|
|
35
45
|
title_border_color = "#ffffff",
|
|
36
|
-
title_border_radius = 0
|
|
46
|
+
title_border_radius = 0,
|
|
47
|
+
math_expression = False,
|
|
48
|
+
title_alignment = Qt.AlignmentFlag.AlignCenter
|
|
37
49
|
):
|
|
38
50
|
main_layout = QVBoxLayout()
|
|
39
51
|
main_layout.setContentsMargins(25, 25, 25, 25)
|
|
@@ -50,7 +62,9 @@ def create_form(
|
|
|
50
62
|
padding_bottom = title_padding_bottom,
|
|
51
63
|
border_width = title_border_width,
|
|
52
64
|
border_color = title_border_color,
|
|
53
|
-
border_radius = title_border_radius
|
|
65
|
+
border_radius = title_border_radius,
|
|
66
|
+
math_expression = math_expression,
|
|
67
|
+
alignment = title_alignment
|
|
54
68
|
))
|
|
55
69
|
body_layout = QHBoxLayout()
|
|
56
70
|
main_layout.addLayout(body_layout)
|
|
@@ -102,7 +116,9 @@ def create_header(
|
|
|
102
116
|
title_padding_bottom = None,
|
|
103
117
|
title_border_width = 0,
|
|
104
118
|
title_border_color = "#ffffff",
|
|
105
|
-
title_border_radius = 0
|
|
119
|
+
title_border_radius = 0,
|
|
120
|
+
math_expression = False,
|
|
121
|
+
title_alignment = Qt.AlignmentFlag.AlignCenter
|
|
106
122
|
):
|
|
107
123
|
main_layout = QVBoxLayout()
|
|
108
124
|
main_layout.setContentsMargins(margin_left, margin_top, margin_right, margin_bottom)
|
|
@@ -119,7 +135,9 @@ def create_header(
|
|
|
119
135
|
padding_bottom = title_padding_bottom,
|
|
120
136
|
border_width = title_border_width,
|
|
121
137
|
border_color = title_border_color,
|
|
122
|
-
border_radius = title_border_radius
|
|
138
|
+
border_radius = title_border_radius,
|
|
139
|
+
math_expression = math_expression,
|
|
140
|
+
alignment = title_alignment
|
|
123
141
|
)
|
|
124
142
|
main_layout.addLayout(title_layout)
|
|
125
143
|
main_layout.addStretch()
|
|
@@ -130,7 +148,7 @@ def create_title(
|
|
|
130
148
|
font_family = "Segoe UI",
|
|
131
149
|
font_size = 36,
|
|
132
150
|
font_color = "#ffffff",
|
|
133
|
-
background_color = "
|
|
151
|
+
background_color = "transparent",
|
|
134
152
|
padding = 15,
|
|
135
153
|
padding_left = None,
|
|
136
154
|
padding_top = None,
|
|
@@ -138,11 +156,12 @@ def create_title(
|
|
|
138
156
|
padding_bottom = None,
|
|
139
157
|
border_width = 0,
|
|
140
158
|
border_color = "#ffffff",
|
|
141
|
-
border_radius = 0
|
|
159
|
+
border_radius = 0,
|
|
160
|
+
math_expression = False,
|
|
161
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
142
162
|
):
|
|
143
163
|
title_layout = QHBoxLayout()
|
|
144
164
|
title_layout.setContentsMargins(0, 0, 0, 25)
|
|
145
|
-
title_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
146
165
|
title_label = create_label(
|
|
147
166
|
text = text,
|
|
148
167
|
font_family = font_family,
|
|
@@ -157,7 +176,9 @@ def create_title(
|
|
|
157
176
|
padding_bottom = padding_bottom,
|
|
158
177
|
border_width = border_width,
|
|
159
178
|
border_color = border_color,
|
|
160
|
-
border_radius = border_radius
|
|
179
|
+
border_radius = border_radius,
|
|
180
|
+
math_expression = math_expression,
|
|
181
|
+
alignment = alignment
|
|
161
182
|
)
|
|
162
183
|
title_layout.addWidget(title_label)
|
|
163
184
|
return title_layout
|
|
@@ -168,18 +189,35 @@ def create_label(
|
|
|
168
189
|
font_size = 14,
|
|
169
190
|
font_color = "#ffffff",
|
|
170
191
|
font_weight = "normal",
|
|
171
|
-
background_color = "
|
|
192
|
+
background_color = "transparent",
|
|
172
193
|
padding = 15,
|
|
173
194
|
padding_left = None,
|
|
174
195
|
padding_top = None,
|
|
175
196
|
padding_right = None,
|
|
176
197
|
padding_bottom = None,
|
|
177
198
|
border_width = 0,
|
|
178
|
-
border_color = "#
|
|
199
|
+
border_color = "#5c5c5c",
|
|
179
200
|
border_radius = 0,
|
|
180
|
-
hover_background_color = "
|
|
201
|
+
hover_background_color = "transparent",
|
|
202
|
+
hover_border_width = 0,
|
|
203
|
+
hover_border_color = "#777777",
|
|
204
|
+
disabled_font_color = "#888888",
|
|
205
|
+
disabled_background_color = "transparent",
|
|
206
|
+
disabled_border_width = 0,
|
|
207
|
+
disabled_border_color = "#4a4a4a",
|
|
208
|
+
math_expression = False,
|
|
209
|
+
transparent_for_mouse = False,
|
|
210
|
+
alignment = None,
|
|
211
|
+
word_wrap = False,
|
|
212
|
+
parent = None
|
|
181
213
|
):
|
|
182
|
-
|
|
214
|
+
if math_expression:
|
|
215
|
+
label = QLabel(latex_to_html(text), parent)
|
|
216
|
+
label.setTextFormat(Qt.TextFormat.RichText)
|
|
217
|
+
else: label = QLabel(text, parent)
|
|
218
|
+
if transparent_for_mouse: label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
|
|
219
|
+
if alignment: label.setAlignment(alignment)
|
|
220
|
+
if word_wrap: label.setWordWrap(True)
|
|
183
221
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
184
222
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
185
223
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -200,6 +238,12 @@ def create_label(
|
|
|
200
238
|
}}
|
|
201
239
|
QLabel:hover{{
|
|
202
240
|
background-color: {hover_background_color};
|
|
241
|
+
border: {hover_border_width}px solid {hover_border_color};
|
|
242
|
+
}}
|
|
243
|
+
QLabel:disabled{{
|
|
244
|
+
color: {disabled_font_color};
|
|
245
|
+
background-color: {disabled_background_color};
|
|
246
|
+
border: {disabled_border_width}px solid {disabled_border_color};
|
|
203
247
|
}}
|
|
204
248
|
"""
|
|
205
249
|
label.setStyleSheet(style)
|
|
@@ -229,15 +273,34 @@ def create_button(
|
|
|
229
273
|
disabled_font_color = "#888888",
|
|
230
274
|
disabled_background_color = "#2d2d2d",
|
|
231
275
|
disabled_border_width = 2,
|
|
232
|
-
disabled_border_color = "#4a4a4a"
|
|
276
|
+
disabled_border_color = "#4a4a4a",
|
|
277
|
+
maximum_width = 360,
|
|
278
|
+
math_expression = False,
|
|
279
|
+
parent = None
|
|
233
280
|
):
|
|
234
|
-
button = QPushButton()
|
|
235
|
-
button.setMaximumWidth(
|
|
236
|
-
main_layout = QVBoxLayout(
|
|
237
|
-
|
|
238
|
-
|
|
281
|
+
button = QPushButton(parent)
|
|
282
|
+
if maximum_width is not None: button.setMaximumWidth(maximum_width)
|
|
283
|
+
main_layout = QVBoxLayout()
|
|
284
|
+
button.setLayout(main_layout)
|
|
285
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
|
286
|
+
label = create_label(
|
|
287
|
+
text = text,
|
|
288
|
+
font_size = font_size,
|
|
289
|
+
font_color = font_color,
|
|
290
|
+
font_weight = "bold",
|
|
291
|
+
padding = padding,
|
|
292
|
+
padding_left = padding_left,
|
|
293
|
+
padding_top = padding_top,
|
|
294
|
+
padding_right = padding_right,
|
|
295
|
+
padding_bottom = padding_bottom,
|
|
296
|
+
disabled_border_width = disabled_border_width,
|
|
297
|
+
transparent_for_mouse = True,
|
|
298
|
+
alignment = Qt.AlignmentFlag.AlignCenter,
|
|
299
|
+
math_expression = math_expression
|
|
300
|
+
)
|
|
239
301
|
label.setWordWrap(True)
|
|
240
302
|
main_layout.addWidget(label)
|
|
303
|
+
button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
|
|
241
304
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
242
305
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
243
306
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -288,6 +351,7 @@ def create_text_box(
|
|
|
288
351
|
border_width = 2,
|
|
289
352
|
border_color = "#5c5c5c",
|
|
290
353
|
border_radius = 0,
|
|
354
|
+
placeholder_font_color = "#888888",
|
|
291
355
|
hover_background_color = "#333333",
|
|
292
356
|
hover_border_width = 3,
|
|
293
357
|
hover_border_color = "#777777",
|
|
@@ -302,10 +366,11 @@ def create_text_box(
|
|
|
302
366
|
hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
|
|
303
367
|
focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
|
|
304
368
|
focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
|
|
305
|
-
hide_text = False
|
|
369
|
+
hide_text = False,
|
|
370
|
+
math_expression = False,
|
|
371
|
+
parent = None
|
|
306
372
|
):
|
|
307
|
-
text_box = QLineEdit()
|
|
308
|
-
text_box.setPlaceholderText(placeholder_text)
|
|
373
|
+
text_box = QLineEdit(parent)
|
|
309
374
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
310
375
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
311
376
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -352,38 +417,83 @@ def create_text_box(
|
|
|
352
417
|
toggle_text_visibility_button.setIconSize(QSize(25, 25))
|
|
353
418
|
toggle_text_visibility_action = QWidgetAction(text_box)
|
|
354
419
|
toggle_text_visibility_action.setDefaultWidget(toggle_text_visibility_button)
|
|
355
|
-
|
|
356
|
-
|
|
420
|
+
text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
|
|
421
|
+
toggle_text_visibility_button.setStyleSheet("""
|
|
422
|
+
QToolButton {
|
|
357
423
|
background-color: transparent;
|
|
358
424
|
border: none;
|
|
359
425
|
margin-right: 10px;
|
|
360
|
-
}
|
|
361
|
-
"""
|
|
362
|
-
|
|
363
|
-
text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
|
|
364
|
-
|
|
426
|
+
}
|
|
427
|
+
""")
|
|
428
|
+
|
|
365
429
|
def update_icon():
|
|
366
430
|
is_password = text_box.echoMode() == QLineEdit.EchoMode.Password
|
|
367
431
|
if text_box.hasFocus(): icon = focused_hide_text_icon if is_password else focused_show_text_icon
|
|
368
432
|
else: icon = hide_text_icon if is_password else show_text_icon
|
|
369
433
|
toggle_text_visibility_button.setIcon(icon)
|
|
370
|
-
|
|
434
|
+
|
|
371
435
|
def toggle_visibility():
|
|
372
436
|
if text_box.echoMode() == QLineEdit.EchoMode.Password: text_box.setEchoMode(QLineEdit.EchoMode.Normal)
|
|
373
437
|
else: text_box.setEchoMode(QLineEdit.EchoMode.Password)
|
|
374
438
|
update_icon()
|
|
375
|
-
|
|
439
|
+
|
|
376
440
|
toggle_text_visibility_button.clicked.connect(toggle_visibility)
|
|
377
441
|
|
|
378
|
-
class
|
|
442
|
+
class _IconFocusWatcher(QObject):
|
|
443
|
+
|
|
444
|
+
def __init__(self, watched, on_focus_change):
|
|
445
|
+
super().__init__(watched)
|
|
446
|
+
self._watched = watched
|
|
447
|
+
self._on_focus_change = on_focus_change
|
|
448
|
+
|
|
379
449
|
def eventFilter(self, watched, event):
|
|
380
|
-
if event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
|
|
450
|
+
if watched is self._watched and event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
|
|
451
|
+
if callable(self._on_focus_change): self._on_focus_change()
|
|
381
452
|
return super().eventFilter(watched, event)
|
|
453
|
+
|
|
454
|
+
icon_focus_watcher = _IconFocusWatcher(text_box, update_icon)
|
|
455
|
+
text_box.installEventFilter(icon_focus_watcher)
|
|
456
|
+
setattr(text_box, "_icon_focus_watcher", icon_focus_watcher)
|
|
457
|
+
|
|
458
|
+
placeholder_label = create_label(
|
|
459
|
+
text = placeholder_text,
|
|
460
|
+
font_family = font_family,
|
|
461
|
+
font_size = font_size,
|
|
462
|
+
font_color = placeholder_font_color,
|
|
463
|
+
font_weight = font_weight,
|
|
464
|
+
padding = padding,
|
|
465
|
+
padding_left = padding_left,
|
|
466
|
+
padding_top = padding_top,
|
|
467
|
+
padding_right = padding_right,
|
|
468
|
+
padding_bottom = padding_bottom,
|
|
469
|
+
math_expression = math_expression,
|
|
470
|
+
transparent_for_mouse = True,
|
|
471
|
+
parent = text_box
|
|
472
|
+
)
|
|
473
|
+
placeholder_label.move(0, 2)
|
|
474
|
+
|
|
475
|
+
def update_placeholder_visibility():
|
|
476
|
+
has_text = bool(text_box.text().strip())
|
|
477
|
+
has_focus = text_box.hasFocus()
|
|
478
|
+
placeholder_label.setVisible(not has_text and not has_focus)
|
|
479
|
+
if hide_text: update_icon()
|
|
480
|
+
|
|
481
|
+
class _PlaceholderFocusWatcher(QObject):
|
|
382
482
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
483
|
+
def __init__(self, watched, on_focus_change):
|
|
484
|
+
super().__init__(watched)
|
|
485
|
+
self._watched = watched
|
|
486
|
+
self._on_focus_change = on_focus_change
|
|
487
|
+
|
|
488
|
+
def eventFilter(self, watched, event):
|
|
489
|
+
if watched is self._watched and event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
|
|
490
|
+
if callable(self._on_focus_change): self._on_focus_change()
|
|
491
|
+
return super().eventFilter(watched, event)
|
|
492
|
+
|
|
493
|
+
placeholder_focus_watcher = _PlaceholderFocusWatcher(text_box, update_placeholder_visibility)
|
|
494
|
+
text_box.installEventFilter(placeholder_focus_watcher)
|
|
495
|
+
setattr(text_box, "_placeholder_focus_watcher", placeholder_focus_watcher)
|
|
496
|
+
update_placeholder_visibility()
|
|
387
497
|
return text_box
|
|
388
498
|
|
|
389
499
|
def create_combo_box(
|
|
@@ -413,21 +523,108 @@ def create_combo_box(
|
|
|
413
523
|
dropdown_background_color = "#1e1e1e",
|
|
414
524
|
dropdown_selection_background_color = "#0078d7",
|
|
415
525
|
dropdown_border_width = 1,
|
|
416
|
-
dropdown_border_color = "#5c5c5c"
|
|
526
|
+
dropdown_border_color = "#5c5c5c",
|
|
527
|
+
math_expression = False,
|
|
528
|
+
parent = None
|
|
417
529
|
):
|
|
418
|
-
combo_box = QComboBox()
|
|
419
|
-
combo_box.
|
|
420
|
-
combo_box.addItems(items)
|
|
421
|
-
combo_box.setCurrentIndex(-1)
|
|
422
|
-
|
|
530
|
+
combo_box = QComboBox(parent)
|
|
531
|
+
combo_box.setAccessibleName("combo_box")
|
|
423
532
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
424
533
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
425
534
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
426
535
|
padding_bottom_value = padding_bottom if padding_bottom is not None else padding
|
|
536
|
+
if math_expression:
|
|
537
|
+
placeholder_label = create_label(
|
|
538
|
+
text = placeholder_text,
|
|
539
|
+
font_family = font_family,
|
|
540
|
+
font_size = font_size,
|
|
541
|
+
font_color = placeholder_font_color,
|
|
542
|
+
padding = padding,
|
|
543
|
+
padding_left = padding_left,
|
|
544
|
+
padding_top = padding_top,
|
|
545
|
+
padding_right = padding_right,
|
|
546
|
+
padding_bottom = padding_bottom,
|
|
547
|
+
math_expression = True,
|
|
548
|
+
transparent_for_mouse = True,
|
|
549
|
+
parent = combo_box
|
|
550
|
+
)
|
|
551
|
+
placeholder_label.move(0, 2)
|
|
552
|
+
|
|
553
|
+
def update_placeholder_visibility():
|
|
554
|
+
has_selection = combo_box.currentIndex() != -1
|
|
555
|
+
placeholder_label.setVisible(not has_selection)
|
|
556
|
+
|
|
557
|
+
combo_box.currentIndexChanged.connect(update_placeholder_visibility)
|
|
558
|
+
update_placeholder_visibility()
|
|
559
|
+
|
|
560
|
+
class RichTextDelegate(QStyledItemDelegate):
|
|
561
|
+
def __init__(
|
|
562
|
+
self,
|
|
563
|
+
parent = None,
|
|
564
|
+
font_color = "#ffffff",
|
|
565
|
+
selection_font_color = "#ffffff"
|
|
566
|
+
):
|
|
567
|
+
super().__init__(parent)
|
|
568
|
+
self.font_color = font_color
|
|
569
|
+
self.selection_font_color = selection_font_color
|
|
570
|
+
|
|
571
|
+
def paint(self, painter, option, index):
|
|
572
|
+
if option.state & QStyle.StateFlag.State_Selected: text_color = self.selection_font_color
|
|
573
|
+
else: text_color = self.font_color
|
|
574
|
+
document = QTextDocument()
|
|
575
|
+
html = f"<span style = \"color:{text_color};\">{index.data(Qt.ItemDataRole.DisplayRole)}</span>"
|
|
576
|
+
document.setHtml(html)
|
|
577
|
+
option.text = ""
|
|
578
|
+
QApplication.style().drawControl(QStyle.ControlElement.CE_ItemViewItem, option, painter)
|
|
579
|
+
painter.save()
|
|
580
|
+
painter.translate(option.rect.left(), option.rect.top() + (option.rect.height() - document.size().height()) / 2)
|
|
581
|
+
document.drawContents(painter)
|
|
582
|
+
painter.restore()
|
|
583
|
+
|
|
584
|
+
delegate = RichTextDelegate(
|
|
585
|
+
parent = combo_box,
|
|
586
|
+
font_color = dropdown_font_color,
|
|
587
|
+
selection_font_color = font_color
|
|
588
|
+
)
|
|
589
|
+
combo_box.setItemDelegate(delegate)
|
|
590
|
+
combo_box.clear()
|
|
591
|
+
for item in items: combo_box.addItem(latex_to_html(item))
|
|
592
|
+
combo_box.view().setTextElideMode(Qt.TextElideMode.ElideNone)
|
|
593
|
+
else:
|
|
594
|
+
combo_box.setPlaceholderText(placeholder_text)
|
|
595
|
+
combo_box.addItems(items)
|
|
596
|
+
combo_box.setCurrentIndex(-1)
|
|
597
|
+
if math_expression:
|
|
598
|
+
selected_item_label = create_label(
|
|
599
|
+
text = "",
|
|
600
|
+
font_family = font_family,
|
|
601
|
+
font_size = font_size,
|
|
602
|
+
font_color = font_color,
|
|
603
|
+
padding = padding,
|
|
604
|
+
padding_left = padding_left,
|
|
605
|
+
padding_top = padding_top,
|
|
606
|
+
padding_right = padding_right,
|
|
607
|
+
padding_bottom = padding_bottom,
|
|
608
|
+
math_expression = True,
|
|
609
|
+
transparent_for_mouse = True,
|
|
610
|
+
alignment = Qt.AlignmentFlag.AlignCenter,
|
|
611
|
+
parent = combo_box
|
|
612
|
+
)
|
|
613
|
+
selected_item_label.setVisible(False)
|
|
427
614
|
|
|
615
|
+
def update_selected_item_display(index):
|
|
616
|
+
if index != -1:
|
|
617
|
+
html_text = combo_box.itemText(index)
|
|
618
|
+
selected_item_label.setText(html_text)
|
|
619
|
+
selected_item_label.setVisible(True)
|
|
620
|
+
else:
|
|
621
|
+
selected_item_label.setVisible(False)
|
|
622
|
+
|
|
623
|
+
combo_box.currentIndexChanged.connect(update_selected_item_display)
|
|
624
|
+
|
|
428
625
|
def get_stylesheet(font_color):
|
|
429
626
|
return f"""
|
|
430
|
-
QComboBox {{
|
|
627
|
+
QComboBox[accessibleName="combo_box"] {{
|
|
431
628
|
font-family: {font_family};
|
|
432
629
|
font-size: {font_size}px;
|
|
433
630
|
color: {font_color};
|
|
@@ -439,12 +636,12 @@ def create_combo_box(
|
|
|
439
636
|
border: {border_width}px solid {border_color};
|
|
440
637
|
border-radius: {border_radius}px;
|
|
441
638
|
}}
|
|
442
|
-
QComboBox:hover {{
|
|
639
|
+
QComboBox[accessibleName="combo_box"]:hover {{
|
|
443
640
|
background-color: {hover_background_color};
|
|
444
641
|
border: {hover_border_width}px solid {hover_border_color};
|
|
445
642
|
}}
|
|
446
|
-
QComboBox:on {{
|
|
447
|
-
color: {on_font_color};
|
|
643
|
+
QComboBox[accessibleName="combo_box"]:on {{
|
|
644
|
+
color: {"transparent" if math_expression else on_font_color};
|
|
448
645
|
background-color: {on_background_color};
|
|
449
646
|
border: {on_border_width}px solid {on_border_color};
|
|
450
647
|
}}
|
|
@@ -460,7 +657,9 @@ def create_combo_box(
|
|
|
460
657
|
"""
|
|
461
658
|
|
|
462
659
|
def change_color(index):
|
|
463
|
-
if index == -1:
|
|
660
|
+
if index == -1:
|
|
661
|
+
text_color = "transparent" if math_expression else placeholder_font_color
|
|
662
|
+
combo_box.setStyleSheet(get_stylesheet(text_color))
|
|
464
663
|
else: combo_box.setStyleSheet(get_stylesheet(font_color))
|
|
465
664
|
|
|
466
665
|
combo_box.currentIndexChanged.connect(change_color)
|
|
@@ -494,9 +693,10 @@ def create_checkbox(
|
|
|
494
693
|
disabled_font_color = "#888888",
|
|
495
694
|
disabled_background_color = "#2d2d2d",
|
|
496
695
|
disabled_border_width = 1,
|
|
497
|
-
disabled_border_color = "#4a4a4a"
|
|
696
|
+
disabled_border_color = "#4a4a4a",
|
|
697
|
+
parent = None
|
|
498
698
|
):
|
|
499
|
-
check_box = QCheckBox(text)
|
|
699
|
+
check_box = QCheckBox(text, parent)
|
|
500
700
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
501
701
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
502
702
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -587,9 +787,10 @@ def create_information_message_box(
|
|
|
587
787
|
button_disabled_font_color = "#888888",
|
|
588
788
|
button_disabled_background_color = "#2d2d2d",
|
|
589
789
|
button_disabled_border_width = 2,
|
|
590
|
-
button_disabled_border_color = "#4a4a4a"
|
|
790
|
+
button_disabled_border_color = "#4a4a4a",
|
|
791
|
+
parent = None
|
|
591
792
|
):
|
|
592
|
-
message_box = QDialog()
|
|
793
|
+
message_box = QDialog(parent)
|
|
593
794
|
message_box.setObjectName("message_box")
|
|
594
795
|
message_box.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
|
595
796
|
message_box.setFixedWidth(360)
|
|
@@ -618,10 +819,10 @@ def create_information_message_box(
|
|
|
618
819
|
padding_bottom = label_padding_bottom,
|
|
619
820
|
border_width = label_border_width,
|
|
620
821
|
border_color = label_border_color,
|
|
621
|
-
border_radius = label_border_radius
|
|
822
|
+
border_radius = label_border_radius,
|
|
823
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
622
824
|
)
|
|
623
825
|
main_layout.addWidget(text_label)
|
|
624
|
-
text_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
625
826
|
text_label.setWordWrap(True)
|
|
626
827
|
accept_button = create_button(
|
|
627
828
|
text = button_text,
|
|
@@ -696,9 +897,10 @@ def create_confirmation_message_box(
|
|
|
696
897
|
button_disabled_font_color = "#888888",
|
|
697
898
|
button_disabled_background_color = "#2d2d2d",
|
|
698
899
|
button_disabled_border_width = 2,
|
|
699
|
-
button_disabled_border_color = "#4a4a4a"
|
|
900
|
+
button_disabled_border_color = "#4a4a4a",
|
|
901
|
+
parent = None
|
|
700
902
|
):
|
|
701
|
-
confirm_message_box = QDialog()
|
|
903
|
+
confirm_message_box = QDialog(parent)
|
|
702
904
|
confirm_message_box.setObjectName("confirm_message_box")
|
|
703
905
|
confirm_message_box.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
|
704
906
|
confirm_message_box.setFixedWidth(360)
|
|
@@ -727,10 +929,10 @@ def create_confirmation_message_box(
|
|
|
727
929
|
padding_bottom = label_padding_bottom,
|
|
728
930
|
border_width = label_border_width,
|
|
729
931
|
border_color = label_border_color,
|
|
730
|
-
border_radius = label_border_radius
|
|
932
|
+
border_radius = label_border_radius,
|
|
933
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
731
934
|
)
|
|
732
935
|
main_layout.addWidget(text_label)
|
|
733
|
-
text_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
734
936
|
text_label.setWordWrap(True)
|
|
735
937
|
buttons_layout = QHBoxLayout()
|
|
736
938
|
main_layout.addLayout(buttons_layout)
|
|
@@ -825,9 +1027,10 @@ def create_list_table(
|
|
|
825
1027
|
hover_scrollbar_handle_border_color = "#777777",
|
|
826
1028
|
pressed_scrollbar_handle_background_color = "#4a4a4a",
|
|
827
1029
|
pressed_scrollbar_handle_border_width = 3,
|
|
828
|
-
pressed_scrollbar_handle_border_color = "#0078d7"
|
|
1030
|
+
pressed_scrollbar_handle_border_color = "#0078d7",
|
|
1031
|
+
parent = None
|
|
829
1032
|
):
|
|
830
|
-
list_table = QTableWidget()
|
|
1033
|
+
list_table = QTableWidget(parent)
|
|
831
1034
|
list_table.verticalHeader().setVisible(False)
|
|
832
1035
|
list_table.setColumnCount(len(column_headers))
|
|
833
1036
|
list_table.setHorizontalHeaderLabels(column_headers)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
gui_utilities/gui_utilities.py,sha256=qn1xAZtKqm6H_u4hKTU7cDVjulnmGwUHMlRqeRd1B1E,52418
|
|
2
|
+
gui_utilities/icons/focused_hide_text_icon.png,sha256=0Ysx7vC-mEVfuSBWx1Zw-UhpqvrTCcIvnQ926wFmuK4,13084
|
|
3
|
+
gui_utilities/icons/focused_show_text_icon.png,sha256=gmZU7RR4FN-9VSzpD00ZkQ8UGbihO2y808Kh3b_TaEg,6739
|
|
4
|
+
gui_utilities/icons/hide_text_icon.png,sha256=f5jq6KaAygWNjzP_Ah6dw6eu8q5ml3m56JTeNSTSgEU,7207
|
|
5
|
+
gui_utilities/icons/show_text_icon.png,sha256=8Vdp2XickPEM-eTb1-qBXf3qmHldSzllMZZfObir9p8,5376
|
|
6
|
+
gui_utilities/tlds/tlds_list.txt,sha256=wIWmAQGVNsY0ZJy7qPW8kItDTCE4PTq8wcUhC2hpjkw,10916
|
|
7
|
+
gui_utilities-1.3.48.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
|
|
8
|
+
gui_utilities-1.3.48.dist-info/METADATA,sha256=16hslmJ7k0LrGpDS4KRGm84CB5LBh3d1KxUbabwK5Yc,266
|
|
9
|
+
gui_utilities-1.3.48.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
gui_utilities-1.3.48.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
|
|
11
|
+
gui_utilities-1.3.48.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
gui_utilities/gui_utilities.py,sha256=6lEpyp9VJw2xv5EUrDLxh4iM-A7haQzIfKfLhR2oqbw,43922
|
|
2
|
-
gui_utilities/icons/focused_hide_text_icon.png,sha256=0Ysx7vC-mEVfuSBWx1Zw-UhpqvrTCcIvnQ926wFmuK4,13084
|
|
3
|
-
gui_utilities/icons/focused_show_text_icon.png,sha256=gmZU7RR4FN-9VSzpD00ZkQ8UGbihO2y808Kh3b_TaEg,6739
|
|
4
|
-
gui_utilities/icons/hide_text_icon.png,sha256=f5jq6KaAygWNjzP_Ah6dw6eu8q5ml3m56JTeNSTSgEU,7207
|
|
5
|
-
gui_utilities/icons/show_text_icon.png,sha256=8Vdp2XickPEM-eTb1-qBXf3qmHldSzllMZZfObir9p8,5376
|
|
6
|
-
gui_utilities/tlds/tlds_list.txt,sha256=wIWmAQGVNsY0ZJy7qPW8kItDTCE4PTq8wcUhC2hpjkw,10916
|
|
7
|
-
gui_utilities-1.3.9.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
|
|
8
|
-
gui_utilities-1.3.9.dist-info/METADATA,sha256=6xPMk-MMJ7NRwjlT61zFIzO_sun9CxvN0fD4QdNEJB4,265
|
|
9
|
-
gui_utilities-1.3.9.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
gui_utilities-1.3.9.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
|
|
11
|
-
gui_utilities-1.3.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|