gui-utilities 1.0.1__tar.gz → 1.1.1__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.0.1
3
+ Version: 1.1.1
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
@@ -18,6 +18,94 @@ def create_window(title, background_color = "#1e1e1e"):
18
18
  window.setLayout(main_layout)
19
19
  return window
20
20
 
21
+ def create_form(
22
+ ui_instance,
23
+ buttons,
24
+ title,
25
+ title_font_family = "Segoe UI",
26
+ title_font_size = 36,
27
+ title_font_color = "#ffffff",
28
+ title_background_color = "#1e1e1e",
29
+ title_padding = 15,
30
+ title_border_width = 0,
31
+ title_border_color = "#ffffff",
32
+ title_border_radius = 0
33
+ ):
34
+ main_layout = QVBoxLayout()
35
+ main_layout.setContentsMargins(25, 25, 25, 25)
36
+ main_layout.addLayout(create_title(
37
+ text = title,
38
+ font_family = title_font_family,
39
+ font_size = title_font_size,
40
+ font_color = title_font_color,
41
+ background_color = title_background_color,
42
+ padding = title_padding,
43
+ border_width = title_border_width,
44
+ border_color = title_border_color,
45
+ border_radius = title_border_radius
46
+ ))
47
+ body_layout = QHBoxLayout()
48
+ main_layout.addLayout(body_layout)
49
+ body_layout.setSpacing(25)
50
+ menu_layout = QVBoxLayout()
51
+ body_layout.addLayout(menu_layout)
52
+ menu_layout.setSpacing(10)
53
+ normal_buttons = []
54
+ special_buttons = []
55
+ for button_properties in buttons:
56
+ if button_properties.get("text") in ["Atrás", "Salir"]: special_buttons.append(button_properties)
57
+ else: normal_buttons.append(button_properties)
58
+ for button_properties in normal_buttons:
59
+ button_properties_copy = button_properties.copy()
60
+ callback = button_properties_copy.pop("callback", None)
61
+ button = create_button(**button_properties_copy)
62
+ if callback: button.clicked.connect(callback)
63
+ menu_layout.addWidget(button)
64
+ menu_layout.addStretch()
65
+ for button_properties in special_buttons:
66
+ button_properties_copy = button_properties.copy()
67
+ callback = button_properties_copy.pop("callback", None)
68
+ button_properties_copy.setdefault("font_size", 16)
69
+ button = create_button(**button_properties_copy)
70
+ if callback: button.clicked.connect(callback)
71
+ menu_layout.addWidget(button)
72
+ ui_instance.content_widget = QWidget()
73
+ ui_instance.content_widget.setLayout(QVBoxLayout())
74
+ body_layout.addWidget(ui_instance.content_widget)
75
+ ui_instance.content_widget.setStyleSheet("background-color: #333333;")
76
+ body_layout.setStretch(0, 1)
77
+ body_layout.setStretch(1, 4)
78
+ return main_layout
79
+
80
+ def create_title(
81
+ text,
82
+ font_family = "Segoe UI",
83
+ font_size = 36,
84
+ font_color = "#ffffff",
85
+ background_color = "#1e1e1e",
86
+ padding = 15,
87
+ border_width = 0,
88
+ border_color = "#ffffff",
89
+ border_radius = 0
90
+ ):
91
+ title_layout = QHBoxLayout()
92
+ title_layout.setContentsMargins(0, 0, 0, 25)
93
+ title_layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
94
+ title_label = create_label(
95
+ text = text,
96
+ font_family = font_family,
97
+ font_size = font_size,
98
+ font_color = font_color,
99
+ font_weight = "bold",
100
+ background_color = background_color,
101
+ padding = padding,
102
+ border_width = border_width,
103
+ border_color = border_color,
104
+ border_radius = border_radius
105
+ )
106
+ title_layout.addWidget(title_label)
107
+ return title_layout
108
+
21
109
  def create_label(
22
110
  text,
23
111
  font_family = "Segoe UI",
@@ -553,6 +641,28 @@ def switch_instance(gui_instance, menu_function):
553
641
  else: gui_instance.window.layout().addWidget(new_widget)
554
642
  gui_instance.central_widget = new_widget
555
643
 
644
+ def switch_content_widget(content_widget):
645
+ def clear_layout(layout):
646
+ if layout is not None:
647
+ while layout.count():
648
+ item = layout.takeAt(0)
649
+ widget = item.widget()
650
+ child_layout = item.layout()
651
+ if widget is not None:
652
+ widget.setParent(None)
653
+ widget.deleteLater()
654
+ elif child_layout is not None:
655
+ clear_layout(child_layout)
656
+ child_layout.setParent(None)
657
+
658
+ if content_widget.layout() is not None: clear_layout(content_widget.layout())
659
+ for child in content_widget.findChildren(QWidget):
660
+ if child.parent() == content_widget: child.deleteLater()
661
+ main_layout = content_widget.layout()
662
+ main_layout.setContentsMargins(25, 25, 25, 25)
663
+ main_layout.setSpacing(10)
664
+ return main_layout
665
+
556
666
  def get_responsive_width(window, fraction = 3.0):
557
667
  screen_width = window.screen().size().width()
558
668
  return round(screen_width / fraction)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gui_utilities
3
- Version: 1.0.1
3
+ Version: 1.1.1
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.0.1"
3
+ version = "1.1.1"
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