EzQt-Widgets 1.0.0__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.
@@ -0,0 +1,19 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ pyproject.toml
5
+ ezqt_widgets/__init__.py
6
+ ezqt_widgets/button/__init__.py
7
+ ezqt_widgets/button/icon_button.py
8
+ ezqt_widgets/input/__init__.py
9
+ ezqt_widgets/input/untab_textedit.py
10
+ ezqt_widgets/label/__init__.py
11
+ ezqt_widgets/label/framed_label.py
12
+ ezqt_widgets/label/hover_label.py
13
+ ezqt_widgets/label/indicator_label.py
14
+ ezqt_widgets/loader/__init__.py
15
+ ezqt_widgets/loader/circular_loader.py
16
+ ezqt_widgets/toggle/__init__.py
17
+ ezqt_widgets/toggle/clickable_tag_label.py
18
+ ezqt_widgets/toggle/toggle_label.py
19
+ ezqt_widgets/toggle/toggle_radio.py
@@ -0,0 +1,26 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Neuraaak
4
+
5
+ This project is inspired by and partially based on EzQt-App:
6
+ https://pypi.org/project/EzQt-App/
7
+
8
+ Parts of the EzQt-App framework are reused, adapted, and extended in this project.
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # Inclure la doc principale
2
+ include README.md
3
+ include LICENSE
4
+ include MANIFEST.in
5
+
6
+ # Exclure les fichiers inutiles
7
+ exclude build_upload.bat
8
+ prune build
9
+ prune dist
10
+ prune EzQt_Widgets.egg-info
11
+ prune __pycache__
@@ -0,0 +1,84 @@
1
+ Metadata-Version: 2.4
2
+ Name: EzQt_Widgets
3
+ Version: 1.0.0
4
+ Summary: A collection of custom Qt widgets to enhance applications built with EzQt-App. This module provides advanced, reusable, and stylish graphical components, making it easier to develop modern and user-friendly interfaces.
5
+ Author-email: Florian Salort <floriansalort@gmail.com>
6
+ License: MIT
7
+ Keywords: application,framework
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
14
+ Classifier: Topic :: Office/Business
15
+ Requires-Python: <3.13,>=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: PySide6==6.7.3
19
+ Provides-Extra: dev
20
+ Requires-Dist: pytest>=6.2.5; extra == "dev"
21
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
22
+ Requires-Dist: flake8>=4.0.1; extra == "dev"
23
+ Dynamic: license-file
24
+
25
+ # EzQt-Widgets
26
+
27
+ ## Description
28
+
29
+ EzQt-Widgets is a collection of custom Qt widgets designed to enhance applications built with [EzQt-App](https://pypi.org/project/EzQt-App/).
30
+ This module provides advanced, reusable, and stylish graphical components, making it easier to develop modern and user-friendly interfaces.
31
+
32
+ ## Features
33
+
34
+ - Ready-to-use custom widgets for PySide6/Qt applications
35
+ - Consistent design and easy integration with EzQt-App projects
36
+ - Modular and extensible components (buttons, labels, loaders, etc.)
37
+ - Facilitates the creation of modern, ergonomic UIs
38
+
39
+ ## Installation
40
+
41
+ Install via pip (recommended):
42
+
43
+ ```bash
44
+ pip install ezqt_widgets
45
+ ```
46
+
47
+ Or install locally:
48
+
49
+ ```bash
50
+ git clone https://github.com/neuraaak/ezqt_widgets.git
51
+ cd ezqt_widgets
52
+ pip install .
53
+ ```
54
+
55
+ ## Dependencies
56
+
57
+ - PySide6 (installed automatically)
58
+ - Compatible with Python 3.9 to 3.12
59
+
60
+ ## Usage Example
61
+
62
+ ```python
63
+ from ezqt_widgets.widgets.extended.icon_button import IconButton
64
+ from PySide6.QtWidgets import QApplication, QMainWindow
65
+
66
+ app = QApplication([])
67
+ window = QMainWindow()
68
+
69
+ # Example: Add a custom IconButton to your window
70
+ icon_button = IconButton(icon_path="path/to/icon.png", text="Click Me")
71
+ window.setCentralWidget(icon_button)
72
+
73
+ window.show()
74
+ app.exec()
75
+ ```
76
+
77
+ ## Integration with EzQt-App
78
+
79
+ EzQt-Widgets is designed to be seamlessly integrated into any EzQt-App project.
80
+ Simply import the desired widgets and use them as you would with standard Qt widgets.
81
+
82
+ ## License
83
+
84
+ MIT License
@@ -0,0 +1,60 @@
1
+ # EzQt-Widgets
2
+
3
+ ## Description
4
+
5
+ EzQt-Widgets is a collection of custom Qt widgets designed to enhance applications built with [EzQt-App](https://pypi.org/project/EzQt-App/).
6
+ This module provides advanced, reusable, and stylish graphical components, making it easier to develop modern and user-friendly interfaces.
7
+
8
+ ## Features
9
+
10
+ - Ready-to-use custom widgets for PySide6/Qt applications
11
+ - Consistent design and easy integration with EzQt-App projects
12
+ - Modular and extensible components (buttons, labels, loaders, etc.)
13
+ - Facilitates the creation of modern, ergonomic UIs
14
+
15
+ ## Installation
16
+
17
+ Install via pip (recommended):
18
+
19
+ ```bash
20
+ pip install ezqt_widgets
21
+ ```
22
+
23
+ Or install locally:
24
+
25
+ ```bash
26
+ git clone https://github.com/neuraaak/ezqt_widgets.git
27
+ cd ezqt_widgets
28
+ pip install .
29
+ ```
30
+
31
+ ## Dependencies
32
+
33
+ - PySide6 (installed automatically)
34
+ - Compatible with Python 3.9 to 3.12
35
+
36
+ ## Usage Example
37
+
38
+ ```python
39
+ from ezqt_widgets.widgets.extended.icon_button import IconButton
40
+ from PySide6.QtWidgets import QApplication, QMainWindow
41
+
42
+ app = QApplication([])
43
+ window = QMainWindow()
44
+
45
+ # Example: Add a custom IconButton to your window
46
+ icon_button = IconButton(icon_path="path/to/icon.png", text="Click Me")
47
+ window.setCentralWidget(icon_button)
48
+
49
+ window.show()
50
+ app.exec()
51
+ ```
52
+
53
+ ## Integration with EzQt-App
54
+
55
+ EzQt-Widgets is designed to be seamlessly integrated into any EzQt-App project.
56
+ Simply import the desired widgets and use them as you would with standard Qt widgets.
57
+
58
+ ## License
59
+
60
+ MIT License
@@ -0,0 +1,22 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ """
5
+ EzQt_Widgets package initialization.
6
+ """
7
+ __version__ = "1.0.0"
8
+
9
+ # LABEL WIDGETS
10
+ from .label import *
11
+
12
+ # TOGGLE WIDGETS
13
+ from .toggle import *
14
+
15
+ # BUTTON WIDGETS
16
+ from .button import *
17
+
18
+ # INPUT WIDGETS
19
+ from .input import *
20
+
21
+ # LOADER WIDGETS
22
+ from .loader import *
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # ICON BUTTON
5
+ from .icon_button import *
@@ -0,0 +1,107 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Qt,
11
+ QSize,
12
+ )
13
+ from PySide6.QtGui import (
14
+ QIcon,
15
+ )
16
+ from PySide6.QtWidgets import (
17
+ QHBoxLayout,
18
+ QLabel,
19
+ QToolButton,
20
+ )
21
+
22
+ # IMPORT / GUI AND MODULES AND WIDGETS
23
+ # ///////////////////////////////////////////////////////////////
24
+ from ...kernel.app_components import SizePolicy
25
+
26
+ ## ==> GLOBALS
27
+ # ///////////////////////////////////////////////////////////////
28
+
29
+ ## ==> FUNCTIONS
30
+ # ///////////////////////////////////////////////////////////////
31
+
32
+ ## ==> VARIABLES
33
+ # ///////////////////////////////////////////////////////////////
34
+
35
+ # CLASS
36
+ # ///////////////////////////////////////////////////////////////
37
+
38
+
39
+ class IconButton(QToolButton):
40
+ def __init__(self, parent=None, *args, **kwargs) -> None:
41
+ super().__init__(parent, *args, **kwargs)
42
+ self.setProperty("type", "IconButton")
43
+ self.setContentsMargins(10, 0, 0, 0)
44
+
45
+ self.icon_label = QLabel()
46
+ self.text_label = QLabel()
47
+
48
+ # Appliquer des styles au QLabel pour gérer l'alignement du texte
49
+ self.text_label.setAlignment(
50
+ Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter
51
+ )
52
+ self.text_label.setWordWrap(True)
53
+ self.text_label.setStyleSheet("background-color: rgba(0, 0, 0, 0);")
54
+
55
+ # Configuration de la disposition
56
+ layout = QHBoxLayout(self)
57
+ layout.setContentsMargins(0, 0, 0, 0)
58
+ layout.setSpacing(10) # Espace entre l'icône et le texte
59
+ layout.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
60
+ layout.addWidget(self.icon_label)
61
+ layout.addWidget(self.text_label)
62
+
63
+ # Configurer le bouton pour s'étendre
64
+ self.setSizePolicy(SizePolicy.H_EXPANDING_V_EXPANDING)
65
+
66
+ # //////
67
+ self.text_label.hide()
68
+
69
+ # ///////////////////////////////////////////////////////////////
70
+
71
+ def setIcon(self, icon_path) -> None:
72
+ icon = icon_path if isinstance(icon_path, QIcon) else QIcon(icon_path)
73
+ self.icon_label.setPixmap(
74
+ icon.pixmap(QSize(24, 24))
75
+ ) # Ajuster la taille de l'icône
76
+ self.icon_label.setFixedSize(24, 24) # Fixer la taille du QLabel de l'icône
77
+ self.icon_label.setStyleSheet("background-color: rgba(0, 0, 0, 0);")
78
+
79
+ # ///////////////////////////////////////////////////////////////
80
+
81
+ def setText(self, text) -> None:
82
+ self.text_label.setText(text)
83
+
84
+ # ///////////////////////////////////////////////////////////////
85
+
86
+ def setTextAlignment(self, alignment) -> None:
87
+ self.text_label.setAlignment(alignment)
88
+
89
+ # ///////////////////////////////////////////////////////////////
90
+
91
+ def setSpacing(self, spacing) -> None:
92
+ layout = self.layout()
93
+ layout.setSpacing(spacing)
94
+
95
+ # ///////////////////////////////////////////////////////////////
96
+
97
+ def sizeHint(self) -> QSize:
98
+ return QSize(100, 40) # Taille suggérée du bouton
99
+
100
+ # ///////////////////////////////////////////////////////////////
101
+
102
+ def toggleTextVisibility(self) -> None:
103
+ if self.text_label.isHidden():
104
+ self.text_label.show()
105
+ # //////
106
+ else:
107
+ self.text_label.hide()
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # UNTAB TEXTEDIT
5
+ from .untab_textedit import *
@@ -0,0 +1,57 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtGui import (
10
+ QKeySequence,
11
+ )
12
+ from PySide6.QtWidgets import (
13
+ QApplication,
14
+ QPlainTextEdit,
15
+ )
16
+
17
+ # IMPORT / GUI AND MODULES AND WIDGETS
18
+ # ///////////////////////////////////////////////////////////////
19
+
20
+ ## ==> GLOBALS
21
+ # ///////////////////////////////////////////////////////////////
22
+
23
+ ## ==> FUNCTIONS
24
+ # ///////////////////////////////////////////////////////////////
25
+
26
+ ## ==> VARIABLES
27
+ # ///////////////////////////////////////////////////////////////
28
+
29
+ # CLASS
30
+ # ///////////////////////////////////////////////////////////////
31
+
32
+
33
+ class UntabTextEdit(QPlainTextEdit):
34
+ def __init__(self, *args, **kwargs) -> None:
35
+ super().__init__(*args, **kwargs)
36
+ self.setProperty("type", "UntabTextEdit")
37
+
38
+ # EVENT FUNCTIONS
39
+ # ///////////////////////////////////////////////////////////////
40
+
41
+ def keyPressEvent(self, event) -> None:
42
+ """
43
+ Overridden method from QPlainTextEdit. Modifies the behavior of the paste operation.
44
+
45
+ Args:
46
+ event: The event that triggers the method.
47
+ """
48
+ if event.matches(QKeySequence.StandardKey.Paste):
49
+ clipboard = QApplication.clipboard()
50
+ text = clipboard.text()
51
+ text = text.replace("\t", "\n") # Replace tabs with newlines
52
+ lines = text.split("\n") # Split the text into lines
53
+ lines = [line for line in lines if line.strip()] # Remove empty lines
54
+ text = "\n".join(lines) # Join the lines back together
55
+ self.insertPlainText(text)
56
+ else:
57
+ super().keyPressEvent(event)
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # FRAMED LABEL
5
+ from .framed_label import *
6
+
7
+ # INDICATOR LABEL
8
+ from .indicator_label import *
9
+
10
+ # HOVER LABEL
11
+ from .hover_label import *
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Qt,
11
+ )
12
+ from PySide6.QtWidgets import (
13
+ QFrame,
14
+ QLabel,
15
+ QSizePolicy,
16
+ QVBoxLayout,
17
+ )
18
+
19
+ # IMPORT / GUI AND MODULES AND WIDGETS
20
+ # ///////////////////////////////////////////////////////////////
21
+
22
+ ## ==> GLOBALS
23
+ # ///////////////////////////////////////////////////////////////
24
+
25
+ ## ==> FUNCTIONS
26
+ # ///////////////////////////////////////////////////////////////
27
+
28
+ ## ==> VARIABLES
29
+ # ///////////////////////////////////////////////////////////////
30
+
31
+ # CLASS
32
+ # ///////////////////////////////////////////////////////////////
33
+
34
+
35
+ class FramedLabel(QFrame):
36
+ def __init__(self, text="", parent=None, *args, **kwargs) -> None:
37
+ super().__init__(parent, *args, **kwargs)
38
+ self.setStyleSheet("background-color: transparent;")
39
+ self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
40
+
41
+ # //////
42
+ layout = QVBoxLayout(self)
43
+ layout.setSpacing(0)
44
+ layout.setContentsMargins(0, 0, 0, 0)
45
+ layout.setAlignment(Qt.AlignmentFlag.AlignCenter)
46
+
47
+ # //////
48
+ self.label = QLabel(text, self)
49
+ self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)
50
+ # //////
51
+ layout.addWidget(self.label)
52
+
53
+ # ///////////////////////////////////////////////////////////////
54
+
55
+ def text(self) -> str:
56
+ return self.label.text()
57
+
58
+ # STYLE FUNCTIONS
59
+ # ///////////////////////////////////////////////////////////////
60
+
61
+ def refreshStyle(self) -> None:
62
+ self.style().unpolish(self)
63
+ self.style().polish(self)
@@ -0,0 +1,113 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Signal,
11
+ Qt,
12
+ QSize,
13
+ QRect,
14
+ )
15
+ from PySide6.QtWidgets import (
16
+ QLabel,
17
+ )
18
+ from PySide6.QtGui import (
19
+ QPainter,
20
+ QIcon,
21
+ )
22
+
23
+ # IMPORT / GUI AND MODULES AND WIDGETS
24
+ # ///////////////////////////////////////////////////////////////
25
+
26
+ ## ==> GLOBALS
27
+ # ///////////////////////////////////////////////////////////////
28
+
29
+ ## ==> FUNCTIONS
30
+ # ///////////////////////////////////////////////////////////////
31
+
32
+ ## ==> VARIABLES
33
+ # ///////////////////////////////////////////////////////////////
34
+
35
+ # CLASS
36
+ # ///////////////////////////////////////////////////////////////
37
+
38
+
39
+ class HoverLabel(QLabel):
40
+ hoverIconClicked = Signal() # Signal personnalisé
41
+
42
+ def __init__(self, parent=None, icon=None, text="", *args, **kwargs) -> None:
43
+ super().__init__(
44
+ text or "", parent, *args, **kwargs
45
+ ) # Passer le texte en premier, suivi du parent
46
+ self.setProperty("type", "HoverLabel")
47
+ self.hover_icon = QIcon(icon) if icon else None
48
+ self.show_hover_icon = False
49
+ self.opacity = 0.5 # Opacité de l'icône
50
+ self.setMouseTracking(True) # Activer le suivi de la souris
51
+
52
+ # EVENT FUNCTIONS
53
+ # ///////////////////////////////////////////////////////////////
54
+
55
+ def mouseMoveEvent(self, event) -> None:
56
+ vertical_offset = 5
57
+ if self.show_hover_icon and QRect(
58
+ self.width() - 20, (self.height() - 16) // 2 + vertical_offset, 16, 16
59
+ ).contains(event.pos()):
60
+ self.setCursor(
61
+ Qt.CursorShape.PointingHandCursor
62
+ ) # Changer le curseur en main lors du survol de l'icône
63
+ else:
64
+ self.setCursor(
65
+ Qt.CursorShape.ArrowCursor
66
+ ) # Réinitialiser le curseur si ce n'est pas sur l'icône
67
+ super().mouseMoveEvent(event)
68
+
69
+ # ///////////////////////////////////////////////////////////////
70
+
71
+ def mousePressEvent(self, event) -> None:
72
+ vertical_offset = 5
73
+ if self.show_hover_icon and QRect(
74
+ self.width() - 20, (self.height() - 16) // 2 + vertical_offset, 16, 16
75
+ ).contains(event.pos()):
76
+ self.hoverIconClicked.emit() # Émission du signal
77
+ super().mousePressEvent(event)
78
+
79
+ # ///////////////////////////////////////////////////////////////
80
+
81
+ def enterEvent(self, event) -> None:
82
+ self.show_hover_icon = True
83
+ self.update() # Demande de redessiner le widget
84
+
85
+ # ///////////////////////////////////////////////////////////////
86
+
87
+ def leaveEvent(self, event) -> None:
88
+ self.show_hover_icon = False
89
+ self.setCursor(Qt.CursorShape.ArrowCursor)
90
+ self.update()
91
+
92
+ # UI FUNCTIONS
93
+ # ///////////////////////////////////////////////////////////////
94
+
95
+ def paintEvent(self, event) -> None:
96
+ super().paintEvent(event)
97
+ if self.show_hover_icon:
98
+ painter = QPainter(self)
99
+ painter.setOpacity(self.opacity) # Appliquer l'opacité
100
+ vertical_offset = 5
101
+ icon_size = QSize(16, 16) # Taille souhaitée de l'icône
102
+ icon_pixmap = self.hover_icon.pixmap(
103
+ icon_size
104
+ ) # Obtenir le QPixmap redimensionné
105
+ icon_rect = QRect(
106
+ self.width() - 20,
107
+ (self.height() - icon_size.height()) // 2 + vertical_offset,
108
+ icon_size.width(),
109
+ icon_size.height(),
110
+ )
111
+ painter.drawPixmap(
112
+ icon_rect, icon_pixmap
113
+ ) # Dessiner le QPixmap redimensionné
@@ -0,0 +1,113 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Qt,
11
+ QSize,
12
+ )
13
+ from PySide6.QtWidgets import (
14
+ QHBoxLayout,
15
+ QFrame,
16
+ QLabel,
17
+ )
18
+ from PySide6.QtGui import (
19
+ QFont,
20
+ )
21
+
22
+ # IMPORT / GUI AND MODULES AND WIDGETS
23
+ # ///////////////////////////////////////////////////////////////
24
+
25
+ ## ==> GLOBALS
26
+ # ///////////////////////////////////////////////////////////////
27
+
28
+ ## ==> FUNCTIONS
29
+ # ///////////////////////////////////////////////////////////////
30
+
31
+ ## ==> VARIABLES
32
+ # ///////////////////////////////////////////////////////////////
33
+
34
+ # CLASS
35
+ # ///////////////////////////////////////////////////////////////
36
+
37
+
38
+ class IndicatorLabel(QFrame):
39
+
40
+ # ///////////////////////////////////////////////////////////////
41
+
42
+ def __init__(self, parent=None, *args, **kwargs) -> None:
43
+ super().__init__(parent, *args, **kwargs)
44
+ self.setProperty("type", "IndicatorLabel")
45
+
46
+ # Configuration initiale du Frame principal
47
+ self.setFrameShape(QFrame.NoFrame)
48
+ self.setFrameShadow(QFrame.Raised)
49
+ self.setContentsMargins(0, 3, 0, 0)
50
+ self.setFixedHeight(30)
51
+
52
+ # Création du layout horizontal pour le statut
53
+ self.status_HLayout = QHBoxLayout(self)
54
+ self.status_HLayout.setObjectName("status_HLayout")
55
+ self.status_HLayout.setAlignment(Qt.AlignmentFlag.AlignTop)
56
+ self.status_HLayout.setContentsMargins(0, 0, 0, 0)
57
+ self.status_HLayout.setSpacing(12)
58
+
59
+ # Création du label pour le statut
60
+ self.status_label = QLabel(parent)
61
+ self.status_label.setObjectName("status_label")
62
+ self.status_label.setFont(QFont("Segoe UI", 10))
63
+ self.status_label.setLineWidth(0)
64
+
65
+ # Ajout du label au layout horizontal
66
+ self.status_HLayout.addWidget(self.status_label, 0, Qt.AlignmentFlag.AlignTop)
67
+
68
+ # Création du label pour la LED
69
+ self.status_led = QLabel(parent)
70
+ self.status_led.setObjectName("status_led")
71
+ self.status_led.setFixedSize(QSize(12, 15))
72
+ self.status_led.setFont(QFont("Segoe UI", 10))
73
+ self.status_led.setLineWidth(0)
74
+ self.set_status_neutral()
75
+
76
+ # Ajout du label LED au layout horizontal
77
+ self.status_HLayout.addWidget(self.status_led, 0, Qt.AlignmentFlag.AlignTop)
78
+
79
+ # STATUS FUNCTIONS
80
+ # ///////////////////////////////////////////////////////////////
81
+
82
+ def set_status_neutral(self) -> None:
83
+ self.status_label.setText("En attente")
84
+ self.setProperty("class", "none")
85
+ self.refreshStyle()
86
+
87
+ # ///////////////////////////////////////////////////////////////
88
+
89
+ def set_status_online(self) -> None:
90
+ self.status_label.setText("En ligne")
91
+ self.setProperty("class", "ok")
92
+ self.refreshStyle()
93
+
94
+ # ///////////////////////////////////////////////////////////////
95
+
96
+ def set_status_partial(self) -> None:
97
+ self.status_label.setText("Services perturbés")
98
+ self.setProperty("class", "partiel")
99
+ self.refreshStyle()
100
+
101
+ # ///////////////////////////////////////////////////////////////
102
+
103
+ def set_status_offline(self) -> None:
104
+ self.status_label.setText("Hors ligne")
105
+ self.setProperty("class", "ko")
106
+ self.refreshStyle()
107
+
108
+ # STYLE FUNCTIONS
109
+ # ///////////////////////////////////////////////////////////////
110
+
111
+ def refreshStyle(self) -> None:
112
+ self.style().unpolish(self)
113
+ self.style().polish(self)
@@ -0,0 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # CIRCULAR LOADER
5
+ from .circular_loader import *
@@ -0,0 +1,109 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Signal,
11
+ QTimer,
12
+ )
13
+ from PySide6.QtWidgets import (
14
+ QWidget,
15
+ )
16
+ from PySide6.QtGui import (
17
+ QPainter,
18
+ QPen,
19
+ QColor,
20
+ )
21
+
22
+ # IMPORT / GUI AND MODULES AND WIDGETS
23
+ # ///////////////////////////////////////////////////////////////
24
+
25
+ ## ==> GLOBALS
26
+ # ///////////////////////////////////////////////////////////////
27
+
28
+ ## ==> FUNCTIONS
29
+ # ///////////////////////////////////////////////////////////////
30
+
31
+ ## ==> VARIABLES
32
+ # ///////////////////////////////////////////////////////////////
33
+
34
+ # CLASS
35
+ # ///////////////////////////////////////////////////////////////
36
+
37
+
38
+ class CircularLoader(QWidget):
39
+ timerReset = Signal()
40
+ clicked = Signal()
41
+
42
+ # ///////////////////////////////////////////////////////////////
43
+
44
+ def __init__(self, parent=None, duration=5000, *args, **kwargs) -> None:
45
+ super().__init__(parent, *args, **kwargs)
46
+ self.setProperty("type", "CircularLoader")
47
+ self.duration = duration
48
+ self.elapsed = 0
49
+ self.timer = QTimer(self)
50
+ self.timer.timeout.connect(self.updateProgress)
51
+
52
+ # EVENT FUNCTIONS
53
+ # ///////////////////////////////////////////////////////////////
54
+
55
+ def mousePressEvent(self, event) -> None:
56
+ self.clicked.emit()
57
+
58
+ # ///////////////////////////////////////////////////////////////
59
+
60
+ def startTimer(self) -> None:
61
+ self.timer.start(1000)
62
+
63
+ # ///////////////////////////////////////////////////////////////
64
+
65
+ def stopTimer(self) -> None:
66
+ self.timer.stop()
67
+
68
+ # ///////////////////////////////////////////////////////////////
69
+
70
+ def updateProgress(self) -> None:
71
+ self.elapsed += 1000
72
+ if self.elapsed > self.duration:
73
+ self.resetTimer()
74
+ self.update() # Mettre à jour le dessin
75
+
76
+ # ///////////////////////////////////////////////////////////////
77
+
78
+ def resetTimer(self) -> None:
79
+ self.elapsed = 0 # Réinitialise le timer
80
+ self.timerReset.emit()
81
+ self.update()
82
+
83
+ # UI FUNCTIONS
84
+ # ///////////////////////////////////////////////////////////////
85
+
86
+ def paintEvent(self, event) -> None:
87
+ painter = QPainter(self)
88
+ painter.setRenderHint(QPainter.Antialiasing)
89
+
90
+ # Taille du widget
91
+ size = min(self.width(), self.height())
92
+
93
+ # Épaisseur du trait adaptée à la taille
94
+ penWidth = size * 0.1 # 10% de la taille du widget
95
+ if penWidth < 1:
96
+ penWidth = 1 # Minimum d'un pixel
97
+
98
+ # Arc gris (fond)
99
+ painter.setPen(QPen(QColor(86, 86, 86), penWidth))
100
+ painter.drawEllipse(
101
+ penWidth, penWidth, size - 2 * penWidth, size - 2 * penWidth
102
+ )
103
+
104
+ # Arc coloré
105
+ painter.setPen(QPen(QColor(150, 205, 50), penWidth))
106
+ angle = int((self.elapsed / self.duration) * 360 * 16)
107
+ painter.drawArc(
108
+ penWidth, penWidth, size - 2 * penWidth, size - 2 * penWidth, 0, angle
109
+ )
@@ -0,0 +1,11 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # CLICKABLE TAG LABEL
5
+ from .clickable_tag_label import *
6
+
7
+ # TOGGLE RADIO
8
+ from .toggle_radio import *
9
+
10
+ # TOGGLE LABEL
11
+ from .toggle_label import *
@@ -0,0 +1,133 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Signal,
11
+ Qt,
12
+ )
13
+ from PySide6.QtWidgets import (
14
+ QHBoxLayout,
15
+ QSizePolicy,
16
+ QFrame,
17
+ QLabel,
18
+ )
19
+ from PySide6.QtGui import (
20
+ QFont,
21
+ QMouseEvent,
22
+ )
23
+
24
+ # IMPORT / GUI AND MODULES AND WIDGETS
25
+ # ///////////////////////////////////////////////////////////////
26
+
27
+ ## ==> GLOBALS
28
+ # ///////////////////////////////////////////////////////////////
29
+
30
+ ## ==> FUNCTIONS
31
+ # ///////////////////////////////////////////////////////////////
32
+
33
+ ## ==> VARIABLES
34
+ # ///////////////////////////////////////////////////////////////
35
+
36
+ # CLASS
37
+ # ///////////////////////////////////////////////////////////////
38
+
39
+
40
+ class ClickableTagLabel(QFrame):
41
+ _enabled = False
42
+ # //////
43
+ clicked = Signal()
44
+ toggle_keyword = Signal(str)
45
+
46
+ # ///////////////////////////////////////////////////////////////
47
+
48
+ def __init__(self, parent=None, *args, **kwargs) -> None:
49
+ super().__init__(parent, *args, **kwargs)
50
+ self.setProperty("type", "ClickableTagLabel")
51
+
52
+ # Configuration initiale du Frame principal
53
+ self.setFrameShape(QFrame.NoFrame)
54
+ self.setFrameShadow(QFrame.Raised)
55
+ self.setContentsMargins(4, 0, 4, 0)
56
+ self.setFixedHeight(20)
57
+
58
+ # Création du layout horizontal pour le statut
59
+ self.status_HLayout = QHBoxLayout(self)
60
+ self.status_HLayout.setObjectName("status_HLayout")
61
+ self.status_HLayout.setAlignment(Qt.AlignmentFlag.AlignLeft)
62
+ self.status_HLayout.setContentsMargins(0, 0, 0, 0)
63
+ self.status_HLayout.setSpacing(12)
64
+
65
+ # Création du label pour le statut
66
+ self.status_label = QLabel(parent)
67
+ self.status_label.setObjectName("tag")
68
+ self.status_label.setFont(QFont("Segoe UI", 8))
69
+ self.status_label.setLineWidth(0)
70
+ self.status_label.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred)
71
+ self.status_label.setAlignment(Qt.AlignmentFlag.AlignHCenter)
72
+ self.status_label.setStyleSheet("color: rgb(86, 86, 86);")
73
+
74
+ # Ajout du label au layout horizontal
75
+ self.status_HLayout.addWidget(self.status_label, 0, Qt.AlignmentFlag.AlignTop)
76
+
77
+ # EVENT FUNCTIONS
78
+ # ///////////////////////////////////////////////////////////////
79
+
80
+ def mousePressEvent(self, event: QMouseEvent) -> None:
81
+ if event.button() == Qt.MouseButton.LeftButton:
82
+ self.toggle_state()
83
+ self.toggle_keyword.emit(self.get_name())
84
+ self.clicked.emit()
85
+ super().mousePressEvent(event)
86
+
87
+ # NAME FUNCTIONS
88
+ # ///////////////////////////////////////////////////////////////
89
+
90
+ def set_name(self, text: str) -> None:
91
+ self.status_label.setText(text)
92
+ self.setObjectName(text)
93
+
94
+ # ///////////////////////////////////////////////////////////////
95
+
96
+ def get_name(self) -> None:
97
+ return self.status_label.text()
98
+
99
+ # STATUS FUNCTIONS
100
+ # ///////////////////////////////////////////////////////////////
101
+
102
+ def toggle_state(self) -> None:
103
+ # //////
104
+ if not self._enabled:
105
+ self.set_enabled()
106
+ self._enabled = True
107
+ # //////
108
+ else:
109
+ self.set_disabled()
110
+ self._enabled = False
111
+
112
+ # ///////////////////////////////////////////////////////////////
113
+
114
+ def set_enabled(self) -> None:
115
+ self.setProperty("class", "enabled")
116
+ self.refreshStyle()
117
+ # //////
118
+ self.adjustSize()
119
+
120
+ # ///////////////////////////////////////////////////////////////
121
+
122
+ def set_disabled(self) -> None:
123
+ self.setProperty("class", "disabled")
124
+ self.refreshStyle()
125
+ # //////
126
+ self.adjustSize()
127
+
128
+ # STYLE FUNCTIONS
129
+ # ///////////////////////////////////////////////////////////////
130
+
131
+ def refreshStyle(self) -> None:
132
+ self.style().unpolish(self)
133
+ self.style().polish(self)
@@ -0,0 +1,93 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+
7
+ # IMPORT SPECS
8
+ # ///////////////////////////////////////////////////////////////
9
+ from PySide6.QtCore import (
10
+ Signal,
11
+ )
12
+ from PySide6.QtWidgets import (
13
+ QLabel,
14
+ )
15
+
16
+ # IMPORT / GUI AND MODULES AND WIDGETS
17
+ # ///////////////////////////////////////////////////////////////
18
+
19
+ ## ==> GLOBALS
20
+ # ///////////////////////////////////////////////////////////////
21
+
22
+ ## ==> FUNCTIONS
23
+ # ///////////////////////////////////////////////////////////////
24
+
25
+ ## ==> VARIABLES
26
+ # ///////////////////////////////////////////////////////////////
27
+
28
+ # CLASS
29
+ # ///////////////////////////////////////////////////////////////
30
+
31
+
32
+ class ToggleLabel(QLabel):
33
+ onClick = Signal()
34
+
35
+ # ///////////////////////////////////////////////////////////////
36
+
37
+ def __init__(self, parent=None, *args, **kwargs) -> None:
38
+ super().__init__(parent, *args, **kwargs)
39
+ self.setProperty("type", "ToggleLabel")
40
+ self.state = "closed"
41
+ self.set_state_closed()
42
+
43
+ # EVENT FUNCTIONS
44
+ # ///////////////////////////////////////////////////////////////
45
+
46
+ def mousePressEvent(self, event) -> None:
47
+ self.toggle_state()
48
+ self.onClick.emit()
49
+ super().mousePressEvent(event)
50
+
51
+ # STATUS FUNCTIONS
52
+ # ///////////////////////////////////////////////////////////////
53
+
54
+ def toggle_state(self) -> None:
55
+ # //////
56
+ if self.state == "closed":
57
+ self.state = "opened"
58
+ self.setProperty("class", "drop_down")
59
+ # //////
60
+ else:
61
+ self.state = "closed"
62
+ self.setProperty("class", "drop_up")
63
+
64
+ # //////
65
+ self.refreshStyle()
66
+
67
+ # ///////////////////////////////////////////////////////////////
68
+
69
+ def set_state_closed(self) -> None:
70
+ self.state = "closed"
71
+ self.setProperty("class", "drop_up")
72
+ # //////
73
+ self.refreshStyle()
74
+
75
+ # ///////////////////////////////////////////////////////////////
76
+
77
+ def set_state_opened(self) -> None:
78
+ self.state = "opened"
79
+ self.setProperty("class", "drop_down")
80
+ # //////
81
+ self.refreshStyle()
82
+
83
+ # ///////////////////////////////////////////////////////////////
84
+
85
+ def get_state(self) -> None:
86
+ return self.state
87
+
88
+ # STYLE FUNCTIONS
89
+ # ///////////////////////////////////////////////////////////////
90
+
91
+ def refreshStyle(self) -> None:
92
+ self.style().unpolish(self)
93
+ self.style().polish(self)
@@ -0,0 +1,141 @@
1
+ # -*- coding: utf-8 -*-
2
+ # ///////////////////////////////////////////////////////////////
3
+
4
+ # IMPORT BASE
5
+ # ///////////////////////////////////////////////////////////////
6
+ from typing import Dict, List
7
+
8
+ # IMPORT SPECS
9
+ # ///////////////////////////////////////////////////////////////
10
+ from PySide6.QtCore import (
11
+ Qt,
12
+ Signal,
13
+ QPropertyAnimation,
14
+ QEasingCurve,
15
+ )
16
+ from PySide6.QtWidgets import (
17
+ QFrame,
18
+ QSizePolicy,
19
+ QGridLayout,
20
+ )
21
+
22
+ # IMPORT / GUI AND MODULES AND WIDGETS
23
+ # ///////////////////////////////////////////////////////////////
24
+ from .framed_label import FramedLabel
25
+ from ...kernel.app_settings import Settings
26
+
27
+ ## ==> GLOBALS
28
+ # ///////////////////////////////////////////////////////////////
29
+
30
+ ## ==> FUNCTIONS
31
+ # ///////////////////////////////////////////////////////////////
32
+
33
+ ## ==> VARIABLES
34
+ # ///////////////////////////////////////////////////////////////
35
+
36
+ # CLASS
37
+ # ///////////////////////////////////////////////////////////////
38
+
39
+
40
+ class ToggleRadio(QFrame):
41
+ clicked = Signal()
42
+
43
+ # ///////////////////////////////////////////////////////////////
44
+ def __init__(
45
+ self, items: List[str], default: str = "", parent=None, *args, **kwargs
46
+ ) -> None:
47
+ super().__init__(parent, *args, **kwargs)
48
+ self.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
49
+
50
+ # //////
51
+ self._value = ""
52
+ self._options_list = items
53
+ self._default = default
54
+ self._options: Dict[str, FramedLabel] = {}
55
+ # //////
56
+ self.initUI()
57
+
58
+ # ///////////////////////////////////////////////////////////////
59
+
60
+ def initUI(self) -> None:
61
+ self.grid = QGridLayout(self)
62
+ self.grid.setObjectName("grid")
63
+ self.grid.setSpacing(0)
64
+ self.grid.setContentsMargins(4, 4, 4, 4)
65
+ self.grid.setAlignment(Qt.AlignmentFlag.AlignCenter)
66
+
67
+ # //////
68
+ self.selector = QFrame(self)
69
+ self.selector.setObjectName("selector")
70
+
71
+ # //////
72
+ for option in self._options_list: # Exemple avec trois labels
73
+ self.add_option(option_text=option)
74
+
75
+ # ///////////////////////////////////////////////////////////////
76
+
77
+ def initialize_selector(self, default: str = "") -> None:
78
+ self._default = default
79
+ # //////
80
+ if self._options:
81
+ # //////
82
+ first_option_key = next(iter(self._options_list), None)
83
+ selected_option = self._options.get(
84
+ self._default.capitalize(), self._options.get(first_option_key)
85
+ )
86
+ default_pos = self.grid.indexOf(selected_option)
87
+
88
+ # //////
89
+ self.grid.addWidget(self.selector, 0, default_pos)
90
+ self.selector.lower() # S'assure que le selector reste en dessous
91
+ self.selector.update() # Force le rafraîchissement si nécessaire
92
+
93
+ # ///////////////////////////////////////////////////////////////
94
+
95
+ def add_option(self, option_text: str) -> None:
96
+ option = FramedLabel(option_text, self)
97
+ option.setObjectName(f"opt_{option_text}")
98
+ option.setFrameShape(QFrame.NoFrame)
99
+ option.setFrameShadow(QFrame.Raised)
100
+ option.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
101
+ # //////
102
+ self.grid.addWidget(option, 0, len(self._options.items()))
103
+
104
+ # //////
105
+ option.mousePressEvent = lambda event, option=option: self.toggle_selection(
106
+ option
107
+ )
108
+ self._options[option_text] = option
109
+
110
+ # ///////////////////////////////////////////////////////////////
111
+
112
+ def get_value_option(self) -> FramedLabel | None:
113
+ return self._options.get(self._value)
114
+
115
+ # ///////////////////////////////////////////////////////////////
116
+
117
+ def toggle_selection(self, option: FramedLabel) -> None:
118
+ self._value = option.text()
119
+ # //////
120
+ self.clicked.emit()
121
+ self.move_selector(option)
122
+
123
+ # ///////////////////////////////////////////////////////////////
124
+
125
+ def move_selector(self, option: FramedLabel) -> None:
126
+
127
+ # Variables d'animation
128
+ start_pos = self.selector.pos()
129
+ end_pos = option.pos()
130
+ # //////
131
+ self.selector.setGeometry(option.geometry())
132
+ self.selector.lower() # S'assure que le selector reste en dessous
133
+ self.selector.update() # Force le rafraîchissement si nécessaire
134
+
135
+ # ANIMATION
136
+ self.selector_animation = QPropertyAnimation(self.selector, b"pos")
137
+ self.selector_animation.setDuration(Settings.Gui.TIME_ANIMATION)
138
+ self.selector_animation.setStartValue(start_pos)
139
+ self.selector_animation.setEndValue(end_pos)
140
+ self.selector_animation.setEasingCurve(QEasingCurve.InOutQuart)
141
+ self.selector_animation.start()
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "EzQt_Widgets"
7
+ version = "1.0.0"
8
+ description = "A collection of custom Qt widgets to enhance applications built with EzQt-App. This module provides advanced, reusable, and stylish graphical components, making it easier to develop modern and user-friendly interfaces."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9,<3.13"
11
+ license = { text = "MIT" }
12
+ authors = [{ name = "Florian Salort", email = "floriansalort@gmail.com" }]
13
+ keywords = ["application", "framework"]
14
+ classifiers = [
15
+ "Programming Language :: Python :: 3",
16
+ "License :: OSI Approved :: MIT License",
17
+ "Operating System :: OS Independent",
18
+ "Development Status :: 3 - Alpha",
19
+ "Intended Audience :: Developers",
20
+ "Topic :: Software Development :: Libraries :: Python Modules",
21
+ "Topic :: Office/Business",
22
+ ]
23
+
24
+ dependencies = [
25
+ "PySide6==6.7.3"
26
+ ]
27
+
28
+ [project.optional-dependencies]
29
+ dev = ["pytest>=6.2.5", "pytest-cov>=3.0.0", "flake8>=4.0.1"]
30
+
31
+ [tool.setuptools.packages.find]
32
+ where = ["."]
33
+ include = ["ezqt_widgets", "ezqt_widgets.*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+