gui-utilities 1.3.9__py3-none-any.whl → 1.3.36__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 +73 -14
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.36.dist-info}/METADATA +1 -1
- gui_utilities-1.3.36.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.36.dist-info}/WHEEL +0 -0
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.36.dist-info}/licenses/LICENSE +0 -0
- {gui_utilities-1.3.9.dist-info → gui_utilities-1.3.36.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
2
|
from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QComboBox, QDialog, QToolButton, QWidgetAction, QCheckBox, QTableWidget, QHeaderView
|
|
3
|
-
from PyQt6.QtGui import QIcon
|
|
3
|
+
from PyQt6.QtGui import QIcon
|
|
4
4
|
import re
|
|
5
5
|
import requests
|
|
6
6
|
import importlib.resources
|
|
@@ -18,7 +18,7 @@ def create_window(title, background_color = "#1e1e1e"):
|
|
|
18
18
|
window.setLayout(main_layout)
|
|
19
19
|
return window
|
|
20
20
|
|
|
21
|
-
def
|
|
21
|
+
def create_menu(
|
|
22
22
|
ui_instance,
|
|
23
23
|
buttons,
|
|
24
24
|
title,
|
|
@@ -130,7 +130,7 @@ def create_title(
|
|
|
130
130
|
font_family = "Segoe UI",
|
|
131
131
|
font_size = 36,
|
|
132
132
|
font_color = "#ffffff",
|
|
133
|
-
background_color = "
|
|
133
|
+
background_color = "transparent",
|
|
134
134
|
padding = 15,
|
|
135
135
|
padding_left = None,
|
|
136
136
|
padding_top = None,
|
|
@@ -168,18 +168,25 @@ def create_label(
|
|
|
168
168
|
font_size = 14,
|
|
169
169
|
font_color = "#ffffff",
|
|
170
170
|
font_weight = "normal",
|
|
171
|
-
background_color = "
|
|
171
|
+
background_color = "transparent",
|
|
172
172
|
padding = 15,
|
|
173
173
|
padding_left = None,
|
|
174
174
|
padding_top = None,
|
|
175
175
|
padding_right = None,
|
|
176
176
|
padding_bottom = None,
|
|
177
177
|
border_width = 0,
|
|
178
|
-
border_color = "#
|
|
178
|
+
border_color = "#5c5c5c",
|
|
179
179
|
border_radius = 0,
|
|
180
|
-
hover_background_color = "
|
|
180
|
+
hover_background_color = "transparent",
|
|
181
|
+
hover_border_width = 0,
|
|
182
|
+
hover_border_color = "#777777",
|
|
183
|
+
disabled_font_color = "#888888",
|
|
184
|
+
disabled_background_color = "transparent",
|
|
185
|
+
disabled_border_width = 0,
|
|
186
|
+
disabled_border_color = "#4a4a4a",
|
|
187
|
+
parent = None
|
|
181
188
|
):
|
|
182
|
-
label = QLabel(text)
|
|
189
|
+
label = QLabel(text, parent)
|
|
183
190
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
184
191
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
185
192
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -200,6 +207,12 @@ def create_label(
|
|
|
200
207
|
}}
|
|
201
208
|
QLabel:hover{{
|
|
202
209
|
background-color: {hover_background_color};
|
|
210
|
+
border: {hover_border_width}px solid {hover_border_color};
|
|
211
|
+
}}
|
|
212
|
+
QLabel:disabled{{
|
|
213
|
+
color: {disabled_font_color};
|
|
214
|
+
background-color: {disabled_background_color};
|
|
215
|
+
border: {disabled_border_width}px solid {disabled_border_color};
|
|
203
216
|
}}
|
|
204
217
|
"""
|
|
205
218
|
label.setStyleSheet(style)
|
|
@@ -229,15 +242,30 @@ def create_button(
|
|
|
229
242
|
disabled_font_color = "#888888",
|
|
230
243
|
disabled_background_color = "#2d2d2d",
|
|
231
244
|
disabled_border_width = 2,
|
|
232
|
-
disabled_border_color = "#4a4a4a"
|
|
245
|
+
disabled_border_color = "#4a4a4a",
|
|
246
|
+
maximum_width = 360
|
|
233
247
|
):
|
|
234
248
|
button = QPushButton()
|
|
235
|
-
button.setMaximumWidth(
|
|
236
|
-
main_layout = QVBoxLayout(
|
|
237
|
-
|
|
249
|
+
button.setMaximumWidth(maximum_width)
|
|
250
|
+
main_layout = QVBoxLayout()
|
|
251
|
+
button.setLayout(main_layout)
|
|
252
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
|
253
|
+
label = create_label(
|
|
254
|
+
text = text,
|
|
255
|
+
font_size = font_size,
|
|
256
|
+
font_color = font_color,
|
|
257
|
+
font_weight = "bold",
|
|
258
|
+
padding = padding,
|
|
259
|
+
padding_left = padding_left,
|
|
260
|
+
padding_top = padding_top,
|
|
261
|
+
padding_right = padding_right,
|
|
262
|
+
padding_bottom = padding_bottom,
|
|
263
|
+
disabled_border_width = disabled_border_width
|
|
264
|
+
)
|
|
238
265
|
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
239
266
|
label.setWordWrap(True)
|
|
240
267
|
main_layout.addWidget(label)
|
|
268
|
+
button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
|
|
241
269
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
242
270
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
243
271
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -288,6 +316,7 @@ def create_text_box(
|
|
|
288
316
|
border_width = 2,
|
|
289
317
|
border_color = "#5c5c5c",
|
|
290
318
|
border_radius = 0,
|
|
319
|
+
placeholder_font_color = "#888888",
|
|
291
320
|
hover_background_color = "#333333",
|
|
292
321
|
hover_border_width = 3,
|
|
293
322
|
hover_border_color = "#777777",
|
|
@@ -302,10 +331,10 @@ def create_text_box(
|
|
|
302
331
|
hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
|
|
303
332
|
focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
|
|
304
333
|
focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
|
|
305
|
-
hide_text = False
|
|
334
|
+
hide_text = False,
|
|
335
|
+
math_expression = False
|
|
306
336
|
):
|
|
307
337
|
text_box = QLineEdit()
|
|
308
|
-
text_box.setPlaceholderText(placeholder_text)
|
|
309
338
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
310
339
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
311
340
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -339,6 +368,36 @@ def create_text_box(
|
|
|
339
368
|
}}
|
|
340
369
|
"""
|
|
341
370
|
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()
|
|
342
401
|
if hide_text:
|
|
343
402
|
show_text_icon = QIcon(show_text_icon_url)
|
|
344
403
|
hide_text_icon = QIcon(hide_text_icon_url)
|
|
@@ -380,7 +439,7 @@ def create_text_box(
|
|
|
380
439
|
if event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut): update_icon()
|
|
381
440
|
return super().eventFilter(watched, event)
|
|
382
441
|
|
|
383
|
-
focus_watcher = FocusWatcher(text_box)
|
|
442
|
+
focus_watcher = FocusWatcher(text_box, on_focus_change = update_icon)
|
|
384
443
|
text_box.installEventFilter(focus_watcher)
|
|
385
444
|
setattr(text_box, "focus_watcher", focus_watcher)
|
|
386
445
|
update_icon()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
gui_utilities/gui_utilities.py,sha256=-H8C-_C4fCj0tJr9Wudc8cVfPL5ij2s3I7yiwqEMqcA,46306
|
|
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.36.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
|
|
8
|
+
gui_utilities-1.3.36.dist-info/METADATA,sha256=fmC5wa_5Q93fAvmZu7HCz9mHWe84ONRtj6ong8WjMuA,266
|
|
9
|
+
gui_utilities-1.3.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
gui_utilities-1.3.36.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
|
|
11
|
+
gui_utilities-1.3.36.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
|