gui-utilities 1.3.16__tar.gz → 1.3.35__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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.3.16
3
+ Version: 1.3.35
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
  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,7 +168,7 @@ 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,
@@ -177,18 +177,16 @@ def create_label(
177
177
  border_width = 0,
178
178
  border_color = "#5c5c5c",
179
179
  border_radius = 0,
180
- hover_background_color = "#1e1e1e",
180
+ hover_background_color = "transparent",
181
181
  hover_border_width = 0,
182
182
  hover_border_color = "#777777",
183
- pressed_background_color = "#1e1e1e",
184
- pressed_border_width = 0,
185
- pressed_border_color = "#0078d7",
186
183
  disabled_font_color = "#888888",
187
- disabled_background_color = "#2d2d2d",
184
+ disabled_background_color = "transparent",
188
185
  disabled_border_width = 0,
189
- disabled_border_color = "#4a4a4a"
186
+ disabled_border_color = "#4a4a4a",
187
+ parent = None
190
188
  ):
191
- label = QLabel(text)
189
+ label = QLabel(text, parent)
192
190
  padding_left_value = padding_left if padding_left is not None else padding
193
191
  padding_top_value = padding_top if padding_top is not None else padding
194
192
  padding_right_value = padding_right if padding_right is not None else padding
@@ -211,10 +209,6 @@ def create_label(
211
209
  background-color: {hover_background_color};
212
210
  border: {hover_border_width}px solid {hover_border_color};
213
211
  }}
214
- QLabel:pressed{{
215
- background-color: {pressed_background_color};
216
- border: {pressed_border_width}px solid {pressed_border_color};
217
- }}
218
212
  QLabel:disabled{{
219
213
  color: {disabled_font_color};
220
214
  background-color: {disabled_background_color};
@@ -248,40 +242,30 @@ def create_button(
248
242
  disabled_font_color = "#888888",
249
243
  disabled_background_color = "#2d2d2d",
250
244
  disabled_border_width = 2,
251
- disabled_border_color = "#4a4a4a"
245
+ disabled_border_color = "#4a4a4a",
246
+ maximum_width = 360
252
247
  ):
253
248
  button = QPushButton()
254
- button.setMaximumWidth(360)
255
- main_layout = QVBoxLayout(button)
249
+ button.setMaximumWidth(maximum_width)
250
+ main_layout = QVBoxLayout()
251
+ button.setLayout(main_layout)
256
252
  main_layout.setContentsMargins(0, 0, 0, 0)
257
253
  label = create_label(
258
254
  text = text,
259
255
  font_size = font_size,
260
256
  font_color = font_color,
261
257
  font_weight = "bold",
262
- background_color = background_color,
263
258
  padding = padding,
264
259
  padding_left = padding_left,
265
260
  padding_top = padding_top,
266
261
  padding_right = padding_right,
267
262
  padding_bottom = padding_bottom,
268
- border_width = border_width,
269
- border_color = border_color,
270
- border_radius = border_radius,
271
- hover_background_color = hover_background_color,
272
- hover_border_width = hover_border_width,
273
- hover_border_color = hover_border_color,
274
- pressed_background_color = pressed_background_color,
275
- pressed_border_width = pressed_border_width,
276
- pressed_border_color = pressed_border_color,
277
- disabled_font_color = disabled_font_color,
278
- disabled_background_color = disabled_background_color,
279
- disabled_border_width = disabled_border_width,
280
- disabled_border_color = disabled_border_color
263
+ disabled_border_width = disabled_border_width
281
264
  )
282
265
  label.setAlignment(Qt.AlignmentFlag.AlignCenter)
283
266
  label.setWordWrap(True)
284
267
  main_layout.addWidget(label)
268
+ button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
285
269
  padding_left_value = padding_left if padding_left is not None else padding
286
270
  padding_top_value = padding_top if padding_top is not None else padding
287
271
  padding_right_value = padding_right if padding_right is not None else padding
@@ -332,6 +316,7 @@ def create_text_box(
332
316
  border_width = 2,
333
317
  border_color = "#5c5c5c",
334
318
  border_radius = 0,
319
+ placeholder_font_color = "#888888",
335
320
  hover_background_color = "#333333",
336
321
  hover_border_width = 3,
337
322
  hover_border_color = "#777777",
@@ -346,10 +331,10 @@ def create_text_box(
346
331
  hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
347
332
  focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
348
333
  focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
349
- hide_text = False
334
+ hide_text = False,
335
+ math_expression = False
350
336
  ):
351
337
  text_box = QLineEdit()
352
- text_box.setPlaceholderText(placeholder_text)
353
338
  padding_left_value = padding_left if padding_left is not None else padding
354
339
  padding_top_value = padding_top if padding_top is not None else padding
355
340
  padding_right_value = padding_right if padding_right is not None else padding
@@ -383,6 +368,36 @@ def create_text_box(
383
368
  }}
384
369
  """
385
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(" ", "&nbsp;")
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()
386
401
  if hide_text:
387
402
  show_text_icon = QIcon(show_text_icon_url)
388
403
  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.16
3
+ Version: 1.3.35
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.16"
3
+ version = "1.3.35"
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