gui-utilities 1.3.3__py3-none-any.whl → 1.3.27__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.
@@ -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, QFont, QFontMetrics
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 create_form(
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 = "#1e1e1e",
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 = "#1e1e1e",
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 = "#ffffff",
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
- font-family: {font_family};
188
- font-size: {font_size}px;
189
- color: {font_color};
190
- font-weight: {font_weight};
191
- background-color: {background_color};
192
- padding-left: {padding_left_value}px;
193
- padding-top: {padding_top_value}px;
194
- padding-right: {padding_right_value}px;
195
- padding-bottom: {padding_bottom_value}px;
196
- border: {border_width}px solid {border_color};
197
- border-radius: {border_radius}px;
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,24 +241,34 @@ 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
247
  button = QPushButton()
229
- button.setMaximumWidth(360)
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)
230
268
  padding_left_value = padding_left if padding_left is not None else padding
231
269
  padding_top_value = padding_top if padding_top is not None else padding
232
270
  padding_right_value = padding_right if padding_right is not None else padding
233
271
  padding_bottom_value = padding_bottom if padding_bottom is not None else padding
234
- max_text_width = 360 - padding_left_value - padding_right_value - 2 * border_width
235
- font = QFont(font_family, font_size)
236
- if font_weight == "bold": font.setWeight(QFont.Weight.Bold)
237
- else: font.setWeight(QFont.Weight.Normal)
238
- metrics = QFontMetrics(font)
239
- text_width = metrics.horizontalAdvance(text)
240
- if text_width > max_text_width:
241
- html_text = f"<div style = \"white-space: normal; text-align: center;\">{text}</div>"
242
- button.setText(html_text)
243
- else: button.setText(text)
244
272
  style_sheet = f"""
245
273
  QPushButton {{
246
274
  font-family: {font_family};
@@ -301,10 +329,10 @@ def create_text_box(
301
329
  hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
302
330
  focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
303
331
  focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
304
- hide_text = False
332
+ hide_text = False,
333
+ math_expression = False
305
334
  ):
306
335
  text_box = QLineEdit()
307
- text_box.setPlaceholderText(placeholder_text)
308
336
  padding_left_value = padding_left if padding_left is not None else padding
309
337
  padding_top_value = padding_top if padding_top is not None else padding
310
338
  padding_right_value = padding_right if padding_right is not None else padding
@@ -338,6 +366,30 @@ def create_text_box(
338
366
  }}
339
367
  """
340
368
  text_box.setStyleSheet(style_sheet)
369
+
370
+ def latex_to_html(expression):
371
+ html_expression = expression
372
+ html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
373
+ html_expression = re.sub(r"([a-zA-Z])_(\d+)", r"\1<sub>\2</sub>", html_expression)
374
+ html_expression = re.sub(r"([a-zA-Z0-9])\^(\d+)", r"\1<sup>\2</sup>", html_expression)
375
+ html_expression = html_expression.replace(" ", "&nbsp;")
376
+ return html_expression
377
+
378
+ if not math_expression: text_box.setPlaceholderText(placeholder_text)
379
+ else:
380
+ html_placeholder = latex_to_html(placeholder_text)
381
+ placeholder_label = QLabel(text_box)
382
+ placeholder_label.setTextFormat(Qt.TextFormat.RichText)
383
+ placeholder_label.setText(f"<span style = \"color: {font_color}; font-family: {font_family}; font-size: {font_size}px;\">{html_placeholder}</span>")
384
+ placeholder_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
385
+ placeholder_label.move(padding_left_value + 2, padding_top_value + 2)
386
+ placeholder_label.show()
387
+
388
+ def update_placeholder_visibility():
389
+ placeholder_label.setVisible(text_box.text() == "")
390
+
391
+ text_box.textChanged.connect(update_placeholder_visibility)
392
+ update_placeholder_visibility()
341
393
  if hide_text:
342
394
  show_text_icon = QIcon(show_text_icon_url)
343
395
  hide_text_icon = QIcon(hide_text_icon_url)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.3.3
3
+ Version: 1.3.27
4
4
  Summary: Librería de utilidades gráficas en PyQt6
5
5
  Author-email: Guido Iván Gross <grossguidoivan@gmail.com>
6
6
  Requires-Python: >=3.8
@@ -0,0 +1,11 @@
1
+ gui_utilities/gui_utilities.py,sha256=dy0LllUZ5mC09HdhMfTzvj1kzNBeztyJPNNUsu_6H0c,46185
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.27.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
8
+ gui_utilities-1.3.27.dist-info/METADATA,sha256=168zHVeB2toYacokpwO1kmBFZalHF3vxp5CQtGdmNIo,266
9
+ gui_utilities-1.3.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ gui_utilities-1.3.27.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
11
+ gui_utilities-1.3.27.dist-info/RECORD,,
@@ -1,11 +0,0 @@
1
- gui_utilities/gui_utilities.py,sha256=IqGEoVxpZARNDGvzz9HkXMZhK0Pw6-Q79suBNiulDYI,43953
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.3.dist-info/licenses/LICENSE,sha256=NNoMFs43kWl1J-aqq7_EsPlBjL5XTccWjZlwrlCR-Xc,1093
8
- gui_utilities-1.3.3.dist-info/METADATA,sha256=8vExBoLuo4z4i33ad2WxgU6txCTWwAhQWd6dbbkbEe4,265
9
- gui_utilities-1.3.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
- gui_utilities-1.3.3.dist-info/top_level.txt,sha256=c4C84nMT41keiX9b1AJJZDBU3kA38c7vOmP9kDie8Lk,14
11
- gui_utilities-1.3.3.dist-info/RECORD,,