gui-utilities 1.3.35__tar.gz → 1.3.42__tar.gz
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-1.3.35 → gui_utilities-1.3.42}/PKG-INFO +1 -1
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/gui_utilities.py +92 -75
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities.egg-info/PKG-INFO +1 -1
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/pyproject.toml +1 -1
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/LICENSE +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/README.md +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/focused_hide_text_icon.png +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/focused_show_text_icon.png +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/hide_text_icon.png +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/show_text_icon.png +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/tlds/tlds_list.txt +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities.egg-info/SOURCES.txt +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities.egg-info/dependency_links.txt +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities.egg-info/requires.txt +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities.egg-info/top_level.txt +0 -0
- {gui_utilities-1.3.35 → gui_utilities-1.3.42}/setup.cfg +0 -0
|
@@ -9,8 +9,8 @@ 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 create_window(title, background_color = "#1e1e1e"):
|
|
13
|
-
window = QWidget()
|
|
12
|
+
def create_window(title, background_color = "#1e1e1e", parent = None):
|
|
13
|
+
window = QWidget(parent)
|
|
14
14
|
window.setObjectName("window")
|
|
15
15
|
window.setWindowTitle(title)
|
|
16
16
|
window.setStyleSheet(f"#window {{background-color: {background_color};}}")
|
|
@@ -33,7 +33,9 @@ def create_menu(
|
|
|
33
33
|
title_padding_bottom = None,
|
|
34
34
|
title_border_width = 0,
|
|
35
35
|
title_border_color = "#ffffff",
|
|
36
|
-
title_border_radius = 0
|
|
36
|
+
title_border_radius = 0,
|
|
37
|
+
math_expression = False,
|
|
38
|
+
title_alignment = Qt.AlignmentFlag.AlignCenter
|
|
37
39
|
):
|
|
38
40
|
main_layout = QVBoxLayout()
|
|
39
41
|
main_layout.setContentsMargins(25, 25, 25, 25)
|
|
@@ -50,7 +52,9 @@ def create_menu(
|
|
|
50
52
|
padding_bottom = title_padding_bottom,
|
|
51
53
|
border_width = title_border_width,
|
|
52
54
|
border_color = title_border_color,
|
|
53
|
-
border_radius = title_border_radius
|
|
55
|
+
border_radius = title_border_radius,
|
|
56
|
+
math_expression = math_expression,
|
|
57
|
+
alignment = title_alignment
|
|
54
58
|
))
|
|
55
59
|
body_layout = QHBoxLayout()
|
|
56
60
|
main_layout.addLayout(body_layout)
|
|
@@ -102,7 +106,9 @@ def create_header(
|
|
|
102
106
|
title_padding_bottom = None,
|
|
103
107
|
title_border_width = 0,
|
|
104
108
|
title_border_color = "#ffffff",
|
|
105
|
-
title_border_radius = 0
|
|
109
|
+
title_border_radius = 0,
|
|
110
|
+
math_expression = False,
|
|
111
|
+
title_alignment = Qt.AlignmentFlag.AlignCenter
|
|
106
112
|
):
|
|
107
113
|
main_layout = QVBoxLayout()
|
|
108
114
|
main_layout.setContentsMargins(margin_left, margin_top, margin_right, margin_bottom)
|
|
@@ -119,7 +125,9 @@ def create_header(
|
|
|
119
125
|
padding_bottom = title_padding_bottom,
|
|
120
126
|
border_width = title_border_width,
|
|
121
127
|
border_color = title_border_color,
|
|
122
|
-
border_radius = title_border_radius
|
|
128
|
+
border_radius = title_border_radius,
|
|
129
|
+
math_expression = math_expression,
|
|
130
|
+
alignment = title_alignment
|
|
123
131
|
)
|
|
124
132
|
main_layout.addLayout(title_layout)
|
|
125
133
|
main_layout.addStretch()
|
|
@@ -138,11 +146,12 @@ def create_title(
|
|
|
138
146
|
padding_bottom = None,
|
|
139
147
|
border_width = 0,
|
|
140
148
|
border_color = "#ffffff",
|
|
141
|
-
border_radius = 0
|
|
149
|
+
border_radius = 0,
|
|
150
|
+
math_expression = False,
|
|
151
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
142
152
|
):
|
|
143
153
|
title_layout = QHBoxLayout()
|
|
144
154
|
title_layout.setContentsMargins(0, 0, 0, 25)
|
|
145
|
-
title_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
146
155
|
title_label = create_label(
|
|
147
156
|
text = text,
|
|
148
157
|
font_family = font_family,
|
|
@@ -157,7 +166,9 @@ def create_title(
|
|
|
157
166
|
padding_bottom = padding_bottom,
|
|
158
167
|
border_width = border_width,
|
|
159
168
|
border_color = border_color,
|
|
160
|
-
border_radius = border_radius
|
|
169
|
+
border_radius = border_radius,
|
|
170
|
+
math_expression = math_expression,
|
|
171
|
+
alignment = alignment
|
|
161
172
|
)
|
|
162
173
|
title_layout.addWidget(title_label)
|
|
163
174
|
return title_layout
|
|
@@ -184,9 +195,29 @@ def create_label(
|
|
|
184
195
|
disabled_background_color = "transparent",
|
|
185
196
|
disabled_border_width = 0,
|
|
186
197
|
disabled_border_color = "#4a4a4a",
|
|
198
|
+
math_expression = False,
|
|
199
|
+
transparent_for_mouse = False,
|
|
200
|
+
alignment = None,
|
|
201
|
+
word_wrap = False,
|
|
187
202
|
parent = None
|
|
188
203
|
):
|
|
189
|
-
|
|
204
|
+
def latex_to_html(expression):
|
|
205
|
+
html_expression = expression
|
|
206
|
+
html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
|
|
207
|
+
html_expression = re.sub(r"_\{([^}]+)\}", r"<sub>\1</sub>", html_expression)
|
|
208
|
+
html_expression = re.sub(r"\^\{([^}]+)\}", r"<sup>\1</sup>", html_expression)
|
|
209
|
+
html_expression = re.sub(r"_([a-zA-Z0-9]+)", r"<sub>\1</sub>", html_expression)
|
|
210
|
+
html_expression = re.sub(r"\^([a-zA-Z0-9]+)", r"<sup>\1</sup>", html_expression)
|
|
211
|
+
html_expression = html_expression.replace(" ", " ")
|
|
212
|
+
return html_expression
|
|
213
|
+
|
|
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)
|
|
190
221
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
191
222
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
192
223
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -243,10 +274,12 @@ def create_button(
|
|
|
243
274
|
disabled_background_color = "#2d2d2d",
|
|
244
275
|
disabled_border_width = 2,
|
|
245
276
|
disabled_border_color = "#4a4a4a",
|
|
246
|
-
maximum_width = 360
|
|
277
|
+
maximum_width = 360,
|
|
278
|
+
math_expression = False,
|
|
279
|
+
parent = None
|
|
247
280
|
):
|
|
248
|
-
button = QPushButton()
|
|
249
|
-
button.setMaximumWidth(maximum_width)
|
|
281
|
+
button = QPushButton(parent)
|
|
282
|
+
if maximum_width is not None: button.setMaximumWidth(maximum_width)
|
|
250
283
|
main_layout = QVBoxLayout()
|
|
251
284
|
button.setLayout(main_layout)
|
|
252
285
|
main_layout.setContentsMargins(0, 0, 0, 0)
|
|
@@ -260,9 +293,11 @@ def create_button(
|
|
|
260
293
|
padding_top = padding_top,
|
|
261
294
|
padding_right = padding_right,
|
|
262
295
|
padding_bottom = padding_bottom,
|
|
263
|
-
disabled_border_width = disabled_border_width
|
|
296
|
+
disabled_border_width = disabled_border_width,
|
|
297
|
+
transparent_for_mouse = True,
|
|
298
|
+
alignment = Qt.AlignmentFlag.AlignCenter,
|
|
299
|
+
math_expression = math_expression
|
|
264
300
|
)
|
|
265
|
-
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
266
301
|
label.setWordWrap(True)
|
|
267
302
|
main_layout.addWidget(label)
|
|
268
303
|
button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
|
|
@@ -332,9 +367,9 @@ def create_text_box(
|
|
|
332
367
|
focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
|
|
333
368
|
focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
|
|
334
369
|
hide_text = False,
|
|
335
|
-
|
|
370
|
+
parent = None
|
|
336
371
|
):
|
|
337
|
-
text_box = QLineEdit()
|
|
372
|
+
text_box = QLineEdit(parent)
|
|
338
373
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
339
374
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
340
375
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -368,36 +403,7 @@ def create_text_box(
|
|
|
368
403
|
}}
|
|
369
404
|
"""
|
|
370
405
|
text_box.setStyleSheet(style_sheet)
|
|
371
|
-
|
|
372
|
-
def latex_to_html(expression):
|
|
373
|
-
html_expression = expression
|
|
374
|
-
html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
|
|
375
|
-
html_expression = re.sub(r"([a-zA-Z])_(\d+)", r"\1<sub>\2</sub>", html_expression)
|
|
376
|
-
html_expression = re.sub(r"([a-zA-Z0-9])\^(\d+)", r"\1<sup>\2</sup>", html_expression)
|
|
377
|
-
html_expression = html_expression.replace(" ", " ")
|
|
378
|
-
return html_expression
|
|
379
|
-
|
|
380
|
-
if not math_expression: text_box.setPlaceholderText(placeholder_text)
|
|
381
|
-
else:
|
|
382
|
-
html_placeholder = latex_to_html(placeholder_text)
|
|
383
|
-
placeholder_label = create_label(
|
|
384
|
-
text = html_placeholder,
|
|
385
|
-
font_color = placeholder_font_color,
|
|
386
|
-
font_family = font_family,
|
|
387
|
-
font_size = font_size,
|
|
388
|
-
background_color = "transparent",
|
|
389
|
-
hover_background_color = "transparent",
|
|
390
|
-
disabled_background_color = "transparent",
|
|
391
|
-
parent = text_box
|
|
392
|
-
)
|
|
393
|
-
placeholder_label.setTextFormat(Qt.TextFormat.RichText)
|
|
394
|
-
placeholder_label.show()
|
|
395
|
-
|
|
396
|
-
def update_placeholder_visibility():
|
|
397
|
-
placeholder_label.setVisible(text_box.text() == "")
|
|
398
|
-
|
|
399
|
-
text_box.textChanged.connect(update_placeholder_visibility)
|
|
400
|
-
update_placeholder_visibility()
|
|
406
|
+
text_box.setPlaceholderText(placeholder_text)
|
|
401
407
|
if hide_text:
|
|
402
408
|
show_text_icon = QIcon(show_text_icon_url)
|
|
403
409
|
hide_text_icon = QIcon(hide_text_icon_url)
|
|
@@ -411,37 +417,43 @@ def create_text_box(
|
|
|
411
417
|
toggle_text_visibility_button.setIconSize(QSize(25, 25))
|
|
412
418
|
toggle_text_visibility_action = QWidgetAction(text_box)
|
|
413
419
|
toggle_text_visibility_action.setDefaultWidget(toggle_text_visibility_button)
|
|
414
|
-
|
|
415
|
-
|
|
420
|
+
text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
|
|
421
|
+
toggle_text_visibility_button.setStyleSheet("""
|
|
422
|
+
QToolButton {
|
|
416
423
|
background-color: transparent;
|
|
417
424
|
border: none;
|
|
418
425
|
margin-right: 10px;
|
|
419
|
-
}
|
|
420
|
-
"""
|
|
421
|
-
toggle_text_visibility_button.setStyleSheet(style_sheet)
|
|
422
|
-
text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
|
|
426
|
+
}
|
|
427
|
+
""")
|
|
423
428
|
|
|
424
429
|
def update_icon():
|
|
425
430
|
is_password = text_box.echoMode() == QLineEdit.EchoMode.Password
|
|
426
431
|
if text_box.hasFocus(): icon = focused_hide_text_icon if is_password else focused_show_text_icon
|
|
427
432
|
else: icon = hide_text_icon if is_password else show_text_icon
|
|
428
433
|
toggle_text_visibility_button.setIcon(icon)
|
|
429
|
-
|
|
434
|
+
|
|
430
435
|
def toggle_visibility():
|
|
431
436
|
if text_box.echoMode() == QLineEdit.EchoMode.Password: text_box.setEchoMode(QLineEdit.EchoMode.Normal)
|
|
432
437
|
else: text_box.setEchoMode(QLineEdit.EchoMode.Password)
|
|
433
438
|
update_icon()
|
|
434
|
-
|
|
439
|
+
|
|
435
440
|
toggle_text_visibility_button.clicked.connect(toggle_visibility)
|
|
436
441
|
|
|
437
|
-
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
|
+
|
|
438
449
|
def eventFilter(self, watched, event):
|
|
439
|
-
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()
|
|
440
452
|
return super().eventFilter(watched, event)
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
text_box.installEventFilter(
|
|
444
|
-
setattr(text_box, "
|
|
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)
|
|
445
457
|
update_icon()
|
|
446
458
|
return text_box
|
|
447
459
|
|
|
@@ -472,9 +484,10 @@ def create_combo_box(
|
|
|
472
484
|
dropdown_background_color = "#1e1e1e",
|
|
473
485
|
dropdown_selection_background_color = "#0078d7",
|
|
474
486
|
dropdown_border_width = 1,
|
|
475
|
-
dropdown_border_color = "#5c5c5c"
|
|
487
|
+
dropdown_border_color = "#5c5c5c",
|
|
488
|
+
parent = None
|
|
476
489
|
):
|
|
477
|
-
combo_box = QComboBox()
|
|
490
|
+
combo_box = QComboBox(parent)
|
|
478
491
|
combo_box.setPlaceholderText(f"{placeholder_text}")
|
|
479
492
|
combo_box.addItems(items)
|
|
480
493
|
combo_box.setCurrentIndex(-1)
|
|
@@ -553,9 +566,10 @@ def create_checkbox(
|
|
|
553
566
|
disabled_font_color = "#888888",
|
|
554
567
|
disabled_background_color = "#2d2d2d",
|
|
555
568
|
disabled_border_width = 1,
|
|
556
|
-
disabled_border_color = "#4a4a4a"
|
|
569
|
+
disabled_border_color = "#4a4a4a",
|
|
570
|
+
parent = None
|
|
557
571
|
):
|
|
558
|
-
check_box = QCheckBox(text)
|
|
572
|
+
check_box = QCheckBox(text, parent)
|
|
559
573
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
560
574
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
561
575
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -646,9 +660,10 @@ def create_information_message_box(
|
|
|
646
660
|
button_disabled_font_color = "#888888",
|
|
647
661
|
button_disabled_background_color = "#2d2d2d",
|
|
648
662
|
button_disabled_border_width = 2,
|
|
649
|
-
button_disabled_border_color = "#4a4a4a"
|
|
663
|
+
button_disabled_border_color = "#4a4a4a",
|
|
664
|
+
parent = None
|
|
650
665
|
):
|
|
651
|
-
message_box = QDialog()
|
|
666
|
+
message_box = QDialog(parent)
|
|
652
667
|
message_box.setObjectName("message_box")
|
|
653
668
|
message_box.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
|
654
669
|
message_box.setFixedWidth(360)
|
|
@@ -677,10 +692,10 @@ def create_information_message_box(
|
|
|
677
692
|
padding_bottom = label_padding_bottom,
|
|
678
693
|
border_width = label_border_width,
|
|
679
694
|
border_color = label_border_color,
|
|
680
|
-
border_radius = label_border_radius
|
|
695
|
+
border_radius = label_border_radius,
|
|
696
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
681
697
|
)
|
|
682
698
|
main_layout.addWidget(text_label)
|
|
683
|
-
text_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
684
699
|
text_label.setWordWrap(True)
|
|
685
700
|
accept_button = create_button(
|
|
686
701
|
text = button_text,
|
|
@@ -755,9 +770,10 @@ def create_confirmation_message_box(
|
|
|
755
770
|
button_disabled_font_color = "#888888",
|
|
756
771
|
button_disabled_background_color = "#2d2d2d",
|
|
757
772
|
button_disabled_border_width = 2,
|
|
758
|
-
button_disabled_border_color = "#4a4a4a"
|
|
773
|
+
button_disabled_border_color = "#4a4a4a",
|
|
774
|
+
parent = None
|
|
759
775
|
):
|
|
760
|
-
confirm_message_box = QDialog()
|
|
776
|
+
confirm_message_box = QDialog(parent)
|
|
761
777
|
confirm_message_box.setObjectName("confirm_message_box")
|
|
762
778
|
confirm_message_box.setWindowFlags(Qt.WindowType.FramelessWindowHint)
|
|
763
779
|
confirm_message_box.setFixedWidth(360)
|
|
@@ -786,10 +802,10 @@ def create_confirmation_message_box(
|
|
|
786
802
|
padding_bottom = label_padding_bottom,
|
|
787
803
|
border_width = label_border_width,
|
|
788
804
|
border_color = label_border_color,
|
|
789
|
-
border_radius = label_border_radius
|
|
805
|
+
border_radius = label_border_radius,
|
|
806
|
+
alignment = Qt.AlignmentFlag.AlignCenter
|
|
790
807
|
)
|
|
791
808
|
main_layout.addWidget(text_label)
|
|
792
|
-
text_label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
793
809
|
text_label.setWordWrap(True)
|
|
794
810
|
buttons_layout = QHBoxLayout()
|
|
795
811
|
main_layout.addLayout(buttons_layout)
|
|
@@ -884,9 +900,10 @@ def create_list_table(
|
|
|
884
900
|
hover_scrollbar_handle_border_color = "#777777",
|
|
885
901
|
pressed_scrollbar_handle_background_color = "#4a4a4a",
|
|
886
902
|
pressed_scrollbar_handle_border_width = 3,
|
|
887
|
-
pressed_scrollbar_handle_border_color = "#0078d7"
|
|
903
|
+
pressed_scrollbar_handle_border_color = "#0078d7",
|
|
904
|
+
parent = None
|
|
888
905
|
):
|
|
889
|
-
list_table = QTableWidget()
|
|
906
|
+
list_table = QTableWidget(parent)
|
|
890
907
|
list_table.verticalHeader().setVisible(False)
|
|
891
908
|
list_table.setColumnCount(len(column_headers))
|
|
892
909
|
list_table.setHorizontalHeaderLabels(column_headers)
|
|
File without changes
|
|
File without changes
|
{gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/focused_hide_text_icon.png
RENAMED
|
File without changes
|
{gui_utilities-1.3.35 → gui_utilities-1.3.42}/gui_utilities/icons/focused_show_text_icon.png
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|