gui-utilities 1.3.13__tar.gz → 1.3.30__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.13
3
+ Version: 1.3.30
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,19 +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",
178
+ border_color = "#5c5c5c",
179
179
  border_radius = 0,
180
- hover_background_color = "#1e1e1e",
181
- pressed_background_color = "#1e1e1e",
180
+ hover_background_color = "transparent",
181
+ hover_border_width = 0,
182
+ hover_border_color = "#777777",
182
183
  disabled_font_color = "#888888",
183
- disabled_background_color = "#2d2d2d"
184
+ disabled_background_color = "transparent",
185
+ disabled_border_width = 0,
186
+ disabled_border_color = "#4a4a4a"
184
187
  ):
185
188
  label = QLabel(text)
186
189
  padding_left_value = padding_left if padding_left is not None else padding
@@ -203,13 +206,12 @@ def create_label(
203
206
  }}
204
207
  QLabel:hover{{
205
208
  background-color: {hover_background_color};
206
- }}
207
- QLabel:pressed{{
208
- background-color: {pressed_background_color};
209
+ border: {hover_border_width}px solid {hover_border_color};
209
210
  }}
210
211
  QLabel:disabled{{
211
212
  color: {disabled_font_color};
212
213
  background-color: {disabled_background_color};
214
+ border: {disabled_border_width}px solid {disabled_border_color};
213
215
  }}
214
216
  """
215
217
  label.setStyleSheet(style)
@@ -239,31 +241,34 @@ def create_button(
239
241
  disabled_font_color = "#888888",
240
242
  disabled_background_color = "#2d2d2d",
241
243
  disabled_border_width = 2,
242
- disabled_border_color = "#4a4a4a"
244
+ disabled_border_color = "#4a4a4a",
245
+ maximum_width = 360
243
246
  ):
244
247
  button = QPushButton()
245
- button.setMaximumWidth(360)
246
- main_layout = QVBoxLayout(button)
248
+ button.setMaximumWidth(maximum_width)
249
+ main_layout = QVBoxLayout()
250
+ button.setLayout(main_layout)
247
251
  main_layout.setContentsMargins(0, 0, 0, 0)
248
252
  label = create_label(
249
253
  text = text,
250
254
  font_size = font_size,
251
255
  font_color = font_color,
252
256
  font_weight = "bold",
253
- background_color = background_color,
254
257
  padding = padding,
255
258
  padding_left = padding_left,
256
259
  padding_top = padding_top,
257
260
  padding_right = padding_right,
258
261
  padding_bottom = padding_bottom,
259
- hover_background_color = hover_background_color,
260
- pressed_background_color = pressed_background_color,
261
- disabled_font_color = disabled_font_color,
262
- disabled_background_color = disabled_background_color
262
+ disabled_border_width = disabled_border_width
263
263
  )
264
264
  label.setAlignment(Qt.AlignmentFlag.AlignCenter)
265
265
  label.setWordWrap(True)
266
266
  main_layout.addWidget(label)
267
+ button.setFixedHeight(main_layout.sizeHint().height() + 2 * border_width)
268
+ padding_left_value = padding_left if padding_left is not None else padding
269
+ padding_top_value = padding_top if padding_top is not None else padding
270
+ padding_right_value = padding_right if padding_right is not None else padding
271
+ padding_bottom_value = padding_bottom if padding_bottom is not None else padding
267
272
  style_sheet = f"""
268
273
  QPushButton {{
269
274
  font-family: {font_family};
@@ -271,7 +276,10 @@ def create_button(
271
276
  color: {font_color};
272
277
  font-weight: {font_weight};
273
278
  background-color: {background_color};
274
- padding: 0px;
279
+ padding-left: {padding_left_value}px;
280
+ padding-top: {padding_top_value}px;
281
+ padding-right: {padding_right_value}px;
282
+ padding-bottom: {padding_bottom_value}px;
275
283
  border: {border_width}px solid {border_color};
276
284
  border-radius: {border_radius}px;
277
285
  }}
@@ -321,10 +329,10 @@ def create_text_box(
321
329
  hide_text_icon_url = str(icons_dir / "hide_text_icon.png"),
322
330
  focused_show_text_icon_url = str(icons_dir / "focused_show_text_icon.png"),
323
331
  focused_hide_text_icon_url = str(icons_dir / "focused_hide_text_icon.png"),
324
- hide_text = False
332
+ hide_text = False,
333
+ math_expression = False
325
334
  ):
326
335
  text_box = QLineEdit()
327
- text_box.setPlaceholderText(placeholder_text)
328
336
  padding_left_value = padding_left if padding_left is not None else padding
329
337
  padding_top_value = padding_top if padding_top is not None else padding
330
338
  padding_right_value = padding_right if padding_right is not None else padding
@@ -358,6 +366,36 @@ def create_text_box(
358
366
  }}
359
367
  """
360
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 = create_label(
382
+ text = html_placeholder,
383
+ font_color = font_color,
384
+ font_family = font_family,
385
+ font_size = font_size,
386
+ background_color = background_color,
387
+ hover_background_color = hover_background_color,
388
+ disabled_background_color = disabled_background_color,
389
+ )
390
+ placeholder_label.setTextFormat(Qt.TextFormat.RichText)
391
+ placeholder_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents)
392
+ placeholder_label.show()
393
+
394
+ def update_placeholder_visibility():
395
+ placeholder_label.setVisible(text_box.text() == "")
396
+
397
+ text_box.textChanged.connect(update_placeholder_visibility)
398
+ update_placeholder_visibility()
361
399
  if hide_text:
362
400
  show_text_icon = QIcon(show_text_icon_url)
363
401
  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.13
3
+ Version: 1.3.30
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.13"
3
+ version = "1.3.30"
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