gui-utilities 1.3.1__py3-none-any.whl → 1.3.26__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.
- gui_utilities/gui_utilities.py +85 -29
- {gui_utilities-1.3.1.dist-info → gui_utilities-1.3.26.dist-info}/METADATA +1 -1
- gui_utilities-1.3.26.dist-info/RECORD +11 -0
- gui_utilities-1.3.1.dist-info/RECORD +0 -11
- {gui_utilities-1.3.1.dist-info → gui_utilities-1.3.26.dist-info}/WHEEL +0 -0
- {gui_utilities-1.3.1.dist-info → gui_utilities-1.3.26.dist-info}/licenses/LICENSE +0 -0
- {gui_utilities-1.3.1.dist-info → gui_utilities-1.3.26.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,15 +168,22 @@ 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 = "#
|
|
179
|
-
border_radius = 0
|
|
178
|
+
border_color = "#5c5c5c",
|
|
179
|
+
border_radius = 0,
|
|
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"
|
|
180
187
|
):
|
|
181
188
|
label = QLabel(text)
|
|
182
189
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
@@ -184,17 +191,28 @@ def create_label(
|
|
|
184
191
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
185
192
|
padding_bottom_value = padding_bottom if padding_bottom is not None else padding
|
|
186
193
|
style = f"""
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
QLabel {{
|
|
195
|
+
font-family: {font_family};
|
|
196
|
+
font-size: {font_size}px;
|
|
197
|
+
color: {font_color};
|
|
198
|
+
font-weight: {font_weight};
|
|
199
|
+
background-color: {background_color};
|
|
200
|
+
padding-left: {padding_left_value}px;
|
|
201
|
+
padding-top: {padding_top_value}px;
|
|
202
|
+
padding-right: {padding_right_value}px;
|
|
203
|
+
padding-bottom: {padding_bottom_value}px;
|
|
204
|
+
border: {border_width}px solid {border_color};
|
|
205
|
+
border-radius: {border_radius}px;
|
|
206
|
+
}}
|
|
207
|
+
QLabel:hover{{
|
|
208
|
+
background-color: {hover_background_color};
|
|
209
|
+
border: {hover_border_width}px solid {hover_border_color};
|
|
210
|
+
}}
|
|
211
|
+
QLabel:disabled{{
|
|
212
|
+
color: {disabled_font_color};
|
|
213
|
+
background-color: {disabled_background_color};
|
|
214
|
+
border: {disabled_border_width}px solid {disabled_border_color};
|
|
215
|
+
}}
|
|
198
216
|
"""
|
|
199
217
|
label.setStyleSheet(style)
|
|
200
218
|
return label
|
|
@@ -223,17 +241,30 @@ def create_button(
|
|
|
223
241
|
disabled_font_color = "#888888",
|
|
224
242
|
disabled_background_color = "#2d2d2d",
|
|
225
243
|
disabled_border_width = 2,
|
|
226
|
-
disabled_border_color = "#4a4a4a"
|
|
244
|
+
disabled_border_color = "#4a4a4a",
|
|
245
|
+
maximum_width = 360
|
|
227
246
|
):
|
|
228
|
-
button = QPushButton(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
247
|
+
button = QPushButton()
|
|
248
|
+
button.setMaximumWidth(maximum_width)
|
|
249
|
+
main_layout = QVBoxLayout()
|
|
250
|
+
button.setLayout(main_layout)
|
|
251
|
+
main_layout.setContentsMargins(0, 0, 0, 0)
|
|
252
|
+
label = create_label(
|
|
253
|
+
text = text,
|
|
254
|
+
font_size = font_size,
|
|
255
|
+
font_color = font_color,
|
|
256
|
+
font_weight = "bold",
|
|
257
|
+
padding = padding,
|
|
258
|
+
padding_left = padding_left,
|
|
259
|
+
padding_top = padding_top,
|
|
260
|
+
padding_right = padding_right,
|
|
261
|
+
padding_bottom = padding_bottom,
|
|
262
|
+
disabled_border_width = disabled_border_width
|
|
263
|
+
)
|
|
264
|
+
label.setAlignment(Qt.AlignmentFlag.AlignCenter)
|
|
265
|
+
label.setWordWrap(True)
|
|
266
|
+
main_layout.addWidget(label)
|
|
267
|
+
button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
|
|
237
268
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
238
269
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
239
270
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -298,10 +329,10 @@ def create_text_box(
|
|
|
298
329
|
hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
|
|
299
330
|
focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
|
|
300
331
|
focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
|
|
301
|
-
hide_text = False
|
|
332
|
+
hide_text = False,
|
|
333
|
+
math_expression = False
|
|
302
334
|
):
|
|
303
335
|
text_box = QLineEdit()
|
|
304
|
-
text_box.setPlaceholderText(placeholder_text)
|
|
305
336
|
padding_left_value = padding_left if padding_left is not None else padding
|
|
306
337
|
padding_top_value = padding_top if padding_top is not None else padding
|
|
307
338
|
padding_right_value = padding_right if padding_right is not None else padding
|
|
@@ -335,6 +366,31 @@ def create_text_box(
|
|
|
335
366
|
}}
|
|
336
367
|
"""
|
|
337
368
|
text_box.setStyleSheet(style_sheet)
|
|
369
|
+
|
|
370
|
+
def latex_to_html(expression):
|
|
371
|
+
html_expression = expression
|
|
372
|
+
html_expression = html_expression.replace("\\frac", "frac")
|
|
373
|
+
html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
|
|
374
|
+
html_expression = re.sub(r"([a-zA-Z])_(\d+)", r"\1<sub>\2</sub>", html_expression)
|
|
375
|
+
html_expression = re.sub(r"([a-zA-Z0-9])\^(\d+)", r"\1<sup>\2</sup>", html_expression)
|
|
376
|
+
html_expression = html_expression.replace(" ", " ")
|
|
377
|
+
return html_expression
|
|
378
|
+
|
|
379
|
+
if not math_expression: text_box.setPlaceholderText(placeholder_text)
|
|
380
|
+
else:
|
|
381
|
+
html_placeholder = latex_to_html(placeholder_text)
|
|
382
|
+
placeholder_label = QLabel(text_box)
|
|
383
|
+
placeholder_label.setTextFormat(Qt.TextFormat.RichText)
|
|
384
|
+
placeholder_label.setText(f"<span style = \"color: {font_color}; font-family: {font_family}; font-size: {font_size}px;\">{html_placeholder}</span>")
|
|
385
|
+
placeholder_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
|
|
386
|
+
placeholder_label.move(padding_left_value + 2, padding_top_value + 2)
|
|
387
|
+
placeholder_label.show()
|
|
388
|
+
|
|
389
|
+
def update_placeholder_visibility():
|
|
390
|
+
placeholder_label.setVisible(text_box.text() == "")
|
|
391
|
+
|
|
392
|
+
text_box.textChanged.connect(update_placeholder_visibility)
|
|
393
|
+
update_placeholder_visibility()
|
|
338
394
|
if hide_text:
|
|
339
395
|
show_text_icon = QIcon(show_text_icon_url)
|
|
340
396
|
hide_text_icon = QIcon(hide_text_icon_url)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
gui_utilities/gui_utilities.py,sha256=qUqdTxfDl95epYJBewxLh67kt22lBWimqzFTGgVlO8U,46253
|
|
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.26.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
|
|
8
|
+
gui_utilities-1.3.26.dist-info/METADATA,sha256=K3XEUXjCnhdMgYvBthtznBQcaEJEBpU9QpF1jxfCfFA,266
|
|
9
|
+
gui_utilities-1.3.26.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
+
gui_utilities-1.3.26.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
|
|
11
|
+
gui_utilities-1.3.26.dist-info/RECORD,,
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
gui_utilities/gui_utilities.py,sha256=IqTh577G6GiTpJ9lYgeXr5xXAZmP4ufg3zQ1yHT0EGY,43814
|
|
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.1.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
|
|
8
|
-
gui_utilities-1.3.1.dist-info/METADATA,sha256=mwzrj5V0l-RtUXOZ6Vxe41pjmUTvNN0dpa8gEHVnav0,265
|
|
9
|
-
gui_utilities-1.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
10
|
-
gui_utilities-1.3.1.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
|
|
11
|
-
gui_utilities-1.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|