gui-utilities 1.3.37__tar.gz → 1.3.40__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.37
3
+ Version: 1.3.40
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
@@ -386,18 +386,35 @@ def create_text_box(
386
386
  font_family = font_family,
387
387
  font_size = font_size,
388
388
  background_color = "transparent",
389
- hover_background_color = "transparent",
390
389
  disabled_background_color = "transparent",
391
390
  parent = text_box
392
391
  )
393
392
  placeholder_label.setTextFormat(Qt.TextFormat.RichText)
393
+ placeholder_label.setAttribute(Qt.WidgetAttribute.WA_TransparentForMouseEvents, True)
394
+ placeholder_label.move(0, -2)
394
395
  placeholder_label.show()
395
396
 
396
- def update_placeholder_visibility():
397
- placeholder_label.setVisible(text_box.text() == "")
397
+ class _PlaceholderFocusWatcher(QObject):
398
398
 
399
- text_box.textChanged.connect(update_placeholder_visibility)
400
- update_placeholder_visibility()
399
+ def __init__(self, watched, placeholder_label):
400
+ super().__init__(watched)
401
+ self._watched = watched
402
+ self._placeholder = placeholder_label
403
+
404
+ def eventFilter(self, watched, event):
405
+ if watched is self._watched and event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
406
+ self._placeholder.setVisible((self._watched.text() == "") and (not self._watched.hasFocus()))
407
+ return super().eventFilter(watched, event)
408
+
409
+ def _update_placeholder_visibility():
410
+ if placeholder_label is not None:
411
+ placeholder_label.setVisible(text_box.text() == "" and not text_box.hasFocus())
412
+
413
+ text_box.textChanged.connect(_update_placeholder_visibility)
414
+ focus_watcher_placeholder = _PlaceholderFocusWatcher(text_box, placeholder_label)
415
+ text_box.installEventFilter(focus_watcher_placeholder)
416
+ setattr(text_box, "_placeholder_focus_watcher", focus_watcher_placeholder)
417
+ _update_placeholder_visibility()
401
418
  if hide_text:
402
419
  show_text_icon = QIcon(show_text_icon_url)
403
420
  hide_text_icon = QIcon(hide_text_icon_url)
@@ -411,6 +428,7 @@ def create_text_box(
411
428
  toggle_text_visibility_button.setIconSize(QSize(25, 25))
412
429
  toggle_text_visibility_action = QWidgetAction(text_box)
413
430
  toggle_text_visibility_action.setDefaultWidget(toggle_text_visibility_button)
431
+ text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
414
432
  toggle_text_visibility_button.setStyleSheet("""
415
433
  QToolButton {
416
434
  background-color: transparent;
@@ -418,7 +436,6 @@ def create_text_box(
418
436
  margin-right: 10px;
419
437
  }
420
438
  """)
421
- text_box.addAction(toggle_text_visibility_action, QLineEdit.ActionPosition.TrailingPosition)
422
439
 
423
440
  def update_icon():
424
441
  is_password = text_box.echoMode() == QLineEdit.EchoMode.Password
@@ -433,15 +450,21 @@ def create_text_box(
433
450
 
434
451
  toggle_text_visibility_button.clicked.connect(toggle_visibility)
435
452
 
436
- class FocusWatcher(QObject):
453
+ class _IconFocusWatcher(QObject):
437
454
 
455
+ def __init__(self, watched, on_focus_change):
456
+ super().__init__(watched)
457
+ self._watched = watched
458
+ self._on_focus_change = on_focus_change
459
+
438
460
  def eventFilter(self, watched, event):
439
- if event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut): update_icon()
461
+ if watched is self._watched and event.type() in (QEvent.Type.FocusIn, QEvent.Type.FocusOut):
462
+ if callable(self._on_focus_change): self._on_focus_change()
440
463
  return super().eventFilter(watched, event)
441
464
 
442
- focus_watcher = FocusWatcher(text_box, on_focus_change=update_icon)
443
- text_box.installEventFilter(focus_watcher)
444
- setattr(text_box, "focus_watcher", focus_watcher)
465
+ icon_focus_watcher = _IconFocusWatcher(text_box, update_icon)
466
+ text_box.installEventFilter(icon_focus_watcher)
467
+ setattr(text_box, "_icon_focus_watcher", icon_focus_watcher)
445
468
  update_icon()
446
469
  return text_box
447
470
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.3.37
3
+ Version: 1.3.40
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.37"
3
+ version = "1.3.40"
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