gui-utilities 1.3.53__tar.gz → 1.4.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.3.53
3
+ Version: 1.4.3
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
@@ -1,5 +1,5 @@
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, QApplication, QStyle, QStyledItemDelegate
2
+ from PyQt6.QtWidgets import QWidget, QVBoxLayout, QHBoxLayout, QLabel, QPushButton, QLineEdit, QComboBox, QDialog, QToolButton, QWidgetAction, QCheckBox, QTableWidget, QHeaderView, QApplication, QStyle, QStyledItemDelegate, QScrollArea
3
3
  from PyQt6.QtGui import QIcon, QTextDocument
4
4
  import re
5
5
  import requests
@@ -9,16 +9,6 @@ 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 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(" ", "&nbsp;")
20
- return html_expression
21
-
22
12
  def create_window(title, background_color = "#1e1e1e", parent = None):
23
13
  window = QWidget(parent)
24
14
  window.setObjectName("window")
@@ -93,8 +83,18 @@ def create_menu(
93
83
  menu_layout.addWidget(button)
94
84
  ui_instance.content_widget = QWidget()
95
85
  ui_instance.content_widget.setLayout(QVBoxLayout())
96
- body_layout.addWidget(ui_instance.content_widget)
97
86
  ui_instance.content_widget.setStyleSheet("background-color: #333333;")
87
+ scroll_area = QScrollArea()
88
+ scroll_area.setWidgetResizable(True)
89
+ scroll_area.setWidget(ui_instance.content_widget)
90
+ style_sheet = """
91
+ QScrollArea {
92
+ border: none;
93
+ background-color: #333333;
94
+ }
95
+ """
96
+ scroll_area.setStyleSheet(style_sheet)
97
+ body_layout.addWidget(scroll_area)
98
98
  body_layout.setStretch(0, 1)
99
99
  body_layout.setStretch(1, 4)
100
100
  return main_layout
@@ -212,7 +212,7 @@ def create_label(
212
212
  parent = None
213
213
  ):
214
214
  if math_expression:
215
- label = QLabel(latex_to_html(text), parent)
215
+ label = QLabel(format_html(text), parent)
216
216
  label.setTextFormat(Qt.TextFormat.RichText)
217
217
  else: label = QLabel(text, parent)
218
218
  if transparent_for_mouse: label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
@@ -440,7 +440,6 @@ def create_text_box(
440
440
  toggle_text_visibility_button.clicked.connect(toggle_visibility)
441
441
 
442
442
  class _IconFocusWatcher(QObject):
443
-
444
443
  def __init__(self, watched, on_focus_change):
445
444
  super().__init__(watched)
446
445
  self._watched = watched
@@ -479,7 +478,6 @@ def create_text_box(
479
478
  if hide_text: update_icon()
480
479
 
481
480
  class _PlaceholderFocusWatcher(QObject):
482
-
483
481
  def __init__(self, watched, on_focus_change):
484
482
  super().__init__(watched)
485
483
  self._watched = watched
@@ -588,7 +586,7 @@ def create_combo_box(
588
586
  )
589
587
  combo_box.setItemDelegate(delegate)
590
588
  combo_box.clear()
591
- for item in items: combo_box.addItem(latex_to_html(item))
589
+ for item in items: combo_box.addItem(format_html(item))
592
590
  combo_box.view().setTextElideMode(Qt.TextElideMode.ElideNone)
593
591
  else:
594
592
  combo_box.setPlaceholderText(placeholder_text)
@@ -1242,14 +1240,11 @@ def validate_integer(integer, suffix = "El", field = "campo"):
1242
1240
  if pattern.match(unformatted_integer): return None
1243
1241
  return f"No ha ingresado {"un" if suffix == "El" else "una"} {field} {"válido" if suffix == "El" else "válida"}."
1244
1242
 
1245
- def validate_float(number_str, suffix = "El", field = "campo"):
1246
- if not number_str or not number_str.strip():
1247
- return f"{suffix} {field} no puede dejarse {"vacío" if suffix == "El" else "vacía"}."
1248
- try:
1249
- float(number_str.replace(",", "."))
1250
- return None
1251
- except ValueError:
1252
- return f"No ha ingresado {"un" if suffix == "El" else "una"} {field} {"válido" if suffix == "El" else "válida"}."
1243
+ def validate_float(decimal, suffix = "El", field = "campo"):
1244
+ if not decimal or not decimal.strip(): return f"{suffix} {field} no puede dejarse {"vacío" if suffix == "El" else "vacía"}."
1245
+ pattern = re.compile(r"^-?\d{1,3}(?:\.\d{3})*(?:,\d+)?$|^-?\d+(?:,\d+)?$")
1246
+ if not pattern.match(decimal): return None
1247
+ return f"No ha ingresado {"un" if suffix == "El" else "una"} {field} {"válido" if suffix == "El" else "válida"}."
1253
1248
 
1254
1249
  def validate_id(id_str):
1255
1250
  if not id_str or not id_str.strip(): return "El D.N.I. no puede dejarse vacio."
@@ -1309,14 +1304,9 @@ def validate_email(email):
1309
1304
  if email_pattern.match(email): return None
1310
1305
  return "No ha ingresado un correo electrónico válido."
1311
1306
 
1312
- def decimal_format(number, decimal_places = None):
1313
- if isinstance(number, int):
1314
- return f"{number:,}".replace(",", "X").replace(".", ",").replace("X", ".")
1315
- elif isinstance(number, float):
1316
- if not decimal_places: formatted_str = f"{number:,}"
1317
- else: formatted_str = f"{number:,.{decimal_places}f}"
1318
- return formatted_str.replace(",", "X").replace(".", ",").replace("X", ".")
1319
- return str(number)
1307
+ def decimal_format(number):
1308
+ if isinstance(number, float) and number.is_integer(): number = int(number)
1309
+ return f"{number:,}".replace(",", "X").replace(".", ",").replace("X", ".")
1320
1310
 
1321
1311
  def format_id(id_string):
1322
1312
  clean_id = id_string.replace(".", "")
@@ -1333,4 +1323,14 @@ def format_date(date):
1333
1323
  day = f"{date.day:02d}"
1334
1324
  month = f"{date.month:02d}"
1335
1325
  year = f"{date.year:,}".replace(",", ".")
1336
- return f"{day}/{month}/{year}"
1326
+ return f"{day}/{month}/{year}"
1327
+
1328
+ def format_html(expression):
1329
+ html_expression = expression
1330
+ html_expression = re.sub(r"\\frac\{(.*?)\}\{(.*?)\}", r"<span style='font-size:90%;'>\1⁄\2</span>", html_expression)
1331
+ html_expression = re.sub(r"_\{([^}]+)\}", r"<sub>\1</sub>", html_expression)
1332
+ html_expression = re.sub(r"\^\{([^}]+)\}", r"<sup>\1</sup>", html_expression)
1333
+ html_expression = re.sub(r"_([a-zA-Z0-9]+)", r"<sub>\1</sub>", html_expression)
1334
+ html_expression = re.sub(r"\^([a-zA-Z0-9]+)", r"<sup>\1</sup>", html_expression)
1335
+ html_expression = html_expression.replace(" ", "&nbsp;")
1336
+ return html_expression
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.3.53
3
+ Version: 1.4.3
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "gui_utilities"
3
- version = "1.3.53"
3
+ version = "1.4.3"
4
4
  description = "Librería de utilidades gráficas en PyQt6"
5
5
  authors = [{name = "Guido Iván Gross", email = "grossguidoivan@gmail.com"}]
6
6
  requires-python = ">=3.8"
File without changes
File without changes
File without changes