Python-FastUI-Widgets 1.0.0__py3-none-any.whl
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.
- fastuiwidgets/__init__.py +12 -0
- fastuiwidgets/_rc/__init__.py +0 -0
- fastuiwidgets/_rc/resource.py +98835 -0
- fastuiwidgets/common/__init__.py +12 -0
- fastuiwidgets/common/animation.py +530 -0
- fastuiwidgets/common/auto_wrap.py +164 -0
- fastuiwidgets/common/color.py +95 -0
- fastuiwidgets/common/config.py +423 -0
- fastuiwidgets/common/exception_handler.py +31 -0
- fastuiwidgets/common/font.py +38 -0
- fastuiwidgets/common/icon.py +703 -0
- fastuiwidgets/common/image_utils.py +198 -0
- fastuiwidgets/common/overload.py +47 -0
- fastuiwidgets/common/router.py +133 -0
- fastuiwidgets/common/screen.py +25 -0
- fastuiwidgets/common/smooth_scroll.py +141 -0
- fastuiwidgets/common/style_sheet.py +512 -0
- fastuiwidgets/common/theme_listener.py +27 -0
- fastuiwidgets/common/translator.py +14 -0
- fastuiwidgets/components/__init__.py +6 -0
- fastuiwidgets/components/date_time/__init__.py +4 -0
- fastuiwidgets/components/date_time/calendar_picker.py +121 -0
- fastuiwidgets/components/date_time/calendar_view.py +671 -0
- fastuiwidgets/components/date_time/date_picker.py +245 -0
- fastuiwidgets/components/date_time/fast_calendar_view.py +487 -0
- fastuiwidgets/components/date_time/picker_base.py +632 -0
- fastuiwidgets/components/date_time/time_picker.py +223 -0
- fastuiwidgets/components/dialog_box/__init__.py +6 -0
- fastuiwidgets/components/dialog_box/color_dialog.py +414 -0
- fastuiwidgets/components/dialog_box/dialog.py +167 -0
- fastuiwidgets/components/dialog_box/folder_list_dialog.py +307 -0
- fastuiwidgets/components/dialog_box/mask_dialog_base.py +120 -0
- fastuiwidgets/components/dialog_box/message_box_base.py +92 -0
- fastuiwidgets/components/dialog_box/message_dialog.py +65 -0
- fastuiwidgets/components/layout/__init__.py +3 -0
- fastuiwidgets/components/layout/expand_layout.py +96 -0
- fastuiwidgets/components/layout/flow_layout.py +236 -0
- fastuiwidgets/components/layout/v_box_layout.py +41 -0
- fastuiwidgets/components/material/__init__.py +6 -0
- fastuiwidgets/components/material/acrylic_combo_box.py +96 -0
- fastuiwidgets/components/material/acrylic_flyout.py +105 -0
- fastuiwidgets/components/material/acrylic_line_edit.py +27 -0
- fastuiwidgets/components/material/acrylic_menu.py +204 -0
- fastuiwidgets/components/material/acrylic_tool_tip.py +39 -0
- fastuiwidgets/components/material/acrylic_widget.py +42 -0
- fastuiwidgets/components/navigation/__init__.py +9 -0
- fastuiwidgets/components/navigation/breadcrumb.py +350 -0
- fastuiwidgets/components/navigation/navigation_bar.py +416 -0
- fastuiwidgets/components/navigation/navigation_interface.py +268 -0
- fastuiwidgets/components/navigation/navigation_panel.py +657 -0
- fastuiwidgets/components/navigation/navigation_widget.py +686 -0
- fastuiwidgets/components/navigation/pivot.py +272 -0
- fastuiwidgets/components/navigation/segmented_widget.py +174 -0
- fastuiwidgets/components/settings/__init__.py +8 -0
- fastuiwidgets/components/settings/custom_color_setting_card.py +139 -0
- fastuiwidgets/components/settings/expand_setting_card.py +390 -0
- fastuiwidgets/components/settings/folder_list_setting_card.py +134 -0
- fastuiwidgets/components/settings/options_setting_card.py +86 -0
- fastuiwidgets/components/settings/setting_card.py +449 -0
- fastuiwidgets/components/settings/setting_card_group.py +48 -0
- fastuiwidgets/components/widgets/__init__.py +41 -0
- fastuiwidgets/components/widgets/acrylic_label.py +261 -0
- fastuiwidgets/components/widgets/button.py +1059 -0
- fastuiwidgets/components/widgets/card_widget.py +369 -0
- fastuiwidgets/components/widgets/check_box.py +203 -0
- fastuiwidgets/components/widgets/combo_box.py +556 -0
- fastuiwidgets/components/widgets/command_bar.py +636 -0
- fastuiwidgets/components/widgets/cycle_list_widget.py +251 -0
- fastuiwidgets/components/widgets/flip_view.py +430 -0
- fastuiwidgets/components/widgets/flyout.py +521 -0
- fastuiwidgets/components/widgets/frameless_window.py +49 -0
- fastuiwidgets/components/widgets/icon_widget.py +53 -0
- fastuiwidgets/components/widgets/info_badge.py +483 -0
- fastuiwidgets/components/widgets/info_bar.py +596 -0
- fastuiwidgets/components/widgets/label.py +553 -0
- fastuiwidgets/components/widgets/line_edit.py +551 -0
- fastuiwidgets/components/widgets/list_view.py +158 -0
- fastuiwidgets/components/widgets/menu.py +1318 -0
- fastuiwidgets/components/widgets/pips_pager.py +331 -0
- fastuiwidgets/components/widgets/progress_bar.py +311 -0
- fastuiwidgets/components/widgets/progress_ring.py +212 -0
- fastuiwidgets/components/widgets/scroll_area.py +125 -0
- fastuiwidgets/components/widgets/scroll_bar.py +673 -0
- fastuiwidgets/components/widgets/separator.py +43 -0
- fastuiwidgets/components/widgets/slider.py +307 -0
- fastuiwidgets/components/widgets/spin_box.py +306 -0
- fastuiwidgets/components/widgets/stacked_widget.py +211 -0
- fastuiwidgets/components/widgets/state_tool_tip.py +188 -0
- fastuiwidgets/components/widgets/switch_button.py +312 -0
- fastuiwidgets/components/widgets/tab_view.py +804 -0
- fastuiwidgets/components/widgets/table_view.py +360 -0
- fastuiwidgets/components/widgets/teaching_tip.py +657 -0
- fastuiwidgets/components/widgets/tool_tip.py +460 -0
- fastuiwidgets/components/widgets/tree_view.py +216 -0
- fastuiwidgets/multimedia/__init__.py +3 -0
- fastuiwidgets/multimedia/media_play_bar.py +319 -0
- fastuiwidgets/multimedia/media_player.py +124 -0
- fastuiwidgets/multimedia/video_widget.py +93 -0
- fastuiwidgets/window/__init__.py +2 -0
- fastuiwidgets/window/fluent_window.py +413 -0
- fastuiwidgets/window/splash_screen.py +92 -0
- fastuiwidgets/window/stacked_widget.py +66 -0
- python_fastui_widgets-1.0.0.dist-info/METADATA +30 -0
- python_fastui_widgets-1.0.0.dist-info/RECORD +107 -0
- python_fastui_widgets-1.0.0.dist-info/WHEEL +5 -0
- python_fastui_widgets-1.0.0.dist-info/licenses/LICENSE +674 -0
- python_fastui_widgets-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,212 @@
|
|
1
|
+
# coding:utf-8
|
2
|
+
from PySide6.QtCore import (Qt, QRectF, QEasingCurve, QPropertyAnimation, QParallelAnimationGroup,
|
3
|
+
QSequentialAnimationGroup, Property)
|
4
|
+
from PySide6.QtGui import QColor, QPen, QPainter, QFont
|
5
|
+
from PySide6.QtWidgets import QProgressBar
|
6
|
+
|
7
|
+
from .progress_bar import ProgressBar
|
8
|
+
from ...common.font import setFont
|
9
|
+
from ...common.style_sheet import themeColor, isDarkTheme
|
10
|
+
|
11
|
+
|
12
|
+
class ProgressRing(ProgressBar):
|
13
|
+
""" Progress ring """
|
14
|
+
|
15
|
+
def __init__(self, parent=None, useAni=True):
|
16
|
+
super().__init__(parent, useAni=useAni)
|
17
|
+
self.lightBackgroundColor = QColor(0, 0, 0, 34)
|
18
|
+
self.darkBackgroundColor = QColor(255, 255, 255, 34)
|
19
|
+
self._strokeWidth = 6
|
20
|
+
|
21
|
+
self.setTextVisible(False)
|
22
|
+
self.setFixedSize(100, 100)
|
23
|
+
setFont(self)
|
24
|
+
|
25
|
+
def getStrokeWidth(self):
|
26
|
+
return self._strokeWidth
|
27
|
+
|
28
|
+
def setStrokeWidth(self, w: int):
|
29
|
+
self._strokeWidth = w
|
30
|
+
self.update()
|
31
|
+
|
32
|
+
def _drawText(self, painter: QPainter, text: str):
|
33
|
+
""" draw text """
|
34
|
+
painter.setFont(self.font())
|
35
|
+
painter.setPen(Qt.white if isDarkTheme() else Qt.black)
|
36
|
+
painter.drawText(self.rect(), Qt.AlignCenter, text)
|
37
|
+
|
38
|
+
def paintEvent(self, e):
|
39
|
+
painter = QPainter(self)
|
40
|
+
painter.setRenderHints(QPainter.Antialiasing)
|
41
|
+
|
42
|
+
cw = self._strokeWidth # circle thickness
|
43
|
+
w = min(self.height(), self.width()) - cw
|
44
|
+
rc = QRectF(cw/2, self.height()/2 - w/2, w, w)
|
45
|
+
|
46
|
+
# draw background
|
47
|
+
bc = self.darkBackgroundColor if isDarkTheme() else self.lightBackgroundColor
|
48
|
+
pen = QPen(bc, cw, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
|
49
|
+
painter.setPen(pen)
|
50
|
+
painter.drawArc(rc, 0, 360*16)
|
51
|
+
|
52
|
+
if self.maximum() <= self.minimum():
|
53
|
+
return
|
54
|
+
|
55
|
+
# draw bar
|
56
|
+
pen.setColor(self.barColor())
|
57
|
+
painter.setPen(pen)
|
58
|
+
degree = int(self.val / (self.maximum() - self.minimum()) * 360)
|
59
|
+
painter.drawArc(rc, 90*16, -degree*16)
|
60
|
+
|
61
|
+
# draw text
|
62
|
+
if self.isTextVisible():
|
63
|
+
self._drawText(painter, self.valText())
|
64
|
+
|
65
|
+
strokeWidth = Property(int, getStrokeWidth, setStrokeWidth)
|
66
|
+
|
67
|
+
|
68
|
+
class IndeterminateProgressRing(QProgressBar):
|
69
|
+
""" Indeterminate progress ring """
|
70
|
+
|
71
|
+
def __init__(self, parent=None, start=True):
|
72
|
+
super().__init__(parent=parent)
|
73
|
+
self.lightBackgroundColor = QColor(0, 0, 0, 0)
|
74
|
+
self.darkBackgroundColor = QColor(255, 255, 255, 0)
|
75
|
+
self._lightBarColor = QColor()
|
76
|
+
self._darkBarColor = QColor()
|
77
|
+
self._strokeWidth = 6
|
78
|
+
|
79
|
+
self._startAngle = -180
|
80
|
+
self._spanAngle = 0
|
81
|
+
|
82
|
+
self.startAngleAni1 = QPropertyAnimation(self, b'startAngle', self)
|
83
|
+
self.startAngleAni2 = QPropertyAnimation(self, b'startAngle', self)
|
84
|
+
self.spanAngleAni1 = QPropertyAnimation(self, b'spanAngle', self)
|
85
|
+
self.spanAngleAni2 = QPropertyAnimation(self, b'spanAngle', self)
|
86
|
+
|
87
|
+
self.startAngleAniGroup = QSequentialAnimationGroup(self)
|
88
|
+
self.spanAngleAniGroup = QSequentialAnimationGroup(self)
|
89
|
+
self.aniGroup = QParallelAnimationGroup(self)
|
90
|
+
|
91
|
+
# initialize start angle animation
|
92
|
+
self.startAngleAni1.setDuration(1000)
|
93
|
+
self.startAngleAni1.setStartValue(0)
|
94
|
+
self.startAngleAni1.setEndValue(450)
|
95
|
+
|
96
|
+
self.startAngleAni2.setDuration(1000)
|
97
|
+
self.startAngleAni2.setStartValue(450)
|
98
|
+
self.startAngleAni2.setEndValue(1080)
|
99
|
+
|
100
|
+
self.startAngleAniGroup.addAnimation(self.startAngleAni1)
|
101
|
+
self.startAngleAniGroup.addAnimation(self.startAngleAni2)
|
102
|
+
|
103
|
+
# initialize span angle animation
|
104
|
+
self.spanAngleAni1.setDuration(1000)
|
105
|
+
self.spanAngleAni1.setStartValue(0)
|
106
|
+
self.spanAngleAni1.setEndValue(180)
|
107
|
+
|
108
|
+
self.spanAngleAni2.setDuration(1000)
|
109
|
+
self.spanAngleAni2.setStartValue(180)
|
110
|
+
self.spanAngleAni2.setEndValue(0)
|
111
|
+
|
112
|
+
self.spanAngleAniGroup.addAnimation(self.spanAngleAni1)
|
113
|
+
self.spanAngleAniGroup.addAnimation(self.spanAngleAni2)
|
114
|
+
|
115
|
+
self.aniGroup.addAnimation(self.startAngleAniGroup)
|
116
|
+
self.aniGroup.addAnimation(self.spanAngleAniGroup)
|
117
|
+
self.aniGroup.setLoopCount(-1)
|
118
|
+
|
119
|
+
self.setFixedSize(80, 80)
|
120
|
+
|
121
|
+
if start:
|
122
|
+
self.start()
|
123
|
+
|
124
|
+
@Property(int)
|
125
|
+
def startAngle(self):
|
126
|
+
return self._startAngle
|
127
|
+
|
128
|
+
@startAngle.setter
|
129
|
+
def startAngle(self, angle: int):
|
130
|
+
self._startAngle = angle
|
131
|
+
self.update()
|
132
|
+
|
133
|
+
@Property(int)
|
134
|
+
def spanAngle(self):
|
135
|
+
return self._spanAngle
|
136
|
+
|
137
|
+
@spanAngle.setter
|
138
|
+
def spanAngle(self, angle: int):
|
139
|
+
self._spanAngle = angle
|
140
|
+
self.update()
|
141
|
+
|
142
|
+
def getStrokeWidth(self):
|
143
|
+
return self._strokeWidth
|
144
|
+
|
145
|
+
def setStrokeWidth(self, w: int):
|
146
|
+
self._strokeWidth = w
|
147
|
+
self.update()
|
148
|
+
|
149
|
+
def start(self):
|
150
|
+
""" start spin """
|
151
|
+
self._startAngle = 0
|
152
|
+
self._spanAngle = 0
|
153
|
+
self.aniGroup.start()
|
154
|
+
|
155
|
+
def stop(self):
|
156
|
+
""" stop spin """
|
157
|
+
self.aniGroup.stop()
|
158
|
+
self.startAngle = 0
|
159
|
+
self.spanAngle = 0
|
160
|
+
|
161
|
+
def lightBarColor(self):
|
162
|
+
return self._lightBarColor if self._lightBarColor.isValid() else themeColor()
|
163
|
+
|
164
|
+
def darkBarColor(self):
|
165
|
+
return self._darkBarColor if self._darkBarColor.isValid() else themeColor()
|
166
|
+
|
167
|
+
def setCustomBarColor(self, light, dark):
|
168
|
+
""" set the custom bar color
|
169
|
+
|
170
|
+
Parameters
|
171
|
+
----------
|
172
|
+
light, dark: str | Qt.GlobalColor | QColor
|
173
|
+
bar color in light/dark theme mode
|
174
|
+
"""
|
175
|
+
self._lightBarColor = QColor(light)
|
176
|
+
self._darkBarColor = QColor(dark)
|
177
|
+
self.update()
|
178
|
+
|
179
|
+
def setCustomBackgroundColor(self, light, dark):
|
180
|
+
""" set the custom background color
|
181
|
+
|
182
|
+
Parameters
|
183
|
+
----------
|
184
|
+
light, dark: str | Qt.GlobalColor | QColor
|
185
|
+
background color in light/dark theme mode
|
186
|
+
"""
|
187
|
+
self.lightBackgroundColor = QColor(light)
|
188
|
+
self.darkBackgroundColor = QColor(dark)
|
189
|
+
self.update()
|
190
|
+
|
191
|
+
def paintEvent(self, e):
|
192
|
+
painter = QPainter(self)
|
193
|
+
painter.setRenderHints(QPainter.Antialiasing)
|
194
|
+
|
195
|
+
cw = self._strokeWidth
|
196
|
+
w = min(self.height(), self.width()) - cw
|
197
|
+
rc = QRectF(cw/2, self.height()/2 - w/2, w, w)
|
198
|
+
|
199
|
+
# draw background
|
200
|
+
bc = self.darkBackgroundColor if isDarkTheme() else self.lightBackgroundColor
|
201
|
+
pen = QPen(bc, cw, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)
|
202
|
+
painter.setPen(pen)
|
203
|
+
painter.drawArc(rc, 0, 360*16)
|
204
|
+
|
205
|
+
# draw bar
|
206
|
+
pen.setColor(self.darkBarColor() if isDarkTheme() else self.lightBarColor())
|
207
|
+
painter.setPen(pen)
|
208
|
+
|
209
|
+
startAngle = -self.startAngle + 180
|
210
|
+
painter.drawArc(rc, (startAngle % 360)*16, -self.spanAngle*16)
|
211
|
+
|
212
|
+
strokeWidth = Property(int, getStrokeWidth, setStrokeWidth)
|
@@ -0,0 +1,125 @@
|
|
1
|
+
# coding:utf-8
|
2
|
+
from PySide6.QtCore import QEasingCurve, Qt, QPropertyAnimation
|
3
|
+
from PySide6.QtGui import QWheelEvent
|
4
|
+
from PySide6.QtWidgets import QScrollArea, QScrollBar
|
5
|
+
|
6
|
+
from ...common.smooth_scroll import SmoothScroll, SmoothMode
|
7
|
+
from .scroll_bar import ScrollBar, SmoothScrollBar, SmoothScrollDelegate
|
8
|
+
|
9
|
+
|
10
|
+
class ScrollArea(QScrollArea):
|
11
|
+
""" Smooth scroll area """
|
12
|
+
|
13
|
+
def __init__(self, parent=None):
|
14
|
+
super().__init__(parent)
|
15
|
+
self.scrollDelagate = SmoothScrollDelegate(self)
|
16
|
+
|
17
|
+
def setSmoothMode(self, mode: SmoothMode, orientation: Qt.Orientation):
|
18
|
+
""" set smooth mode
|
19
|
+
|
20
|
+
Parameters
|
21
|
+
----------
|
22
|
+
mode: SmoothMode
|
23
|
+
smooth scroll mode
|
24
|
+
|
25
|
+
orientation: Qt.Orientation
|
26
|
+
scroll direction
|
27
|
+
"""
|
28
|
+
if orientation == Qt.Orientation.Vertical:
|
29
|
+
self.scrollDelagate.verticalSmoothScroll.setSmoothMode(mode)
|
30
|
+
else:
|
31
|
+
self.scrollDelagate.horizonSmoothScroll.setSmoothMode(mode)
|
32
|
+
|
33
|
+
def enableTransparentBackground(self):
|
34
|
+
self.setStyleSheet("QScrollArea{border: none; background: transparent}")
|
35
|
+
|
36
|
+
if self.widget():
|
37
|
+
self.widget().setStyleSheet("QWidget{background: transparent}")
|
38
|
+
|
39
|
+
|
40
|
+
class SingleDirectionScrollArea(QScrollArea):
|
41
|
+
""" Single direction scroll area"""
|
42
|
+
|
43
|
+
def __init__(self, parent=None, orient=Qt.Vertical):
|
44
|
+
"""
|
45
|
+
Parameters
|
46
|
+
----------
|
47
|
+
parent: QWidget
|
48
|
+
parent widget
|
49
|
+
|
50
|
+
orient: Orientation
|
51
|
+
scroll orientation
|
52
|
+
"""
|
53
|
+
super().__init__(parent)
|
54
|
+
self.orient = orient
|
55
|
+
self.smoothScroll = SmoothScroll(self, orient)
|
56
|
+
self.vScrollBar = SmoothScrollBar(Qt.Vertical, self)
|
57
|
+
self.hScrollBar = SmoothScrollBar(Qt.Horizontal, self)
|
58
|
+
|
59
|
+
def setVerticalScrollBarPolicy(self, policy):
|
60
|
+
super().setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
61
|
+
self.vScrollBar.setForceHidden(policy == Qt.ScrollBarAlwaysOff)
|
62
|
+
|
63
|
+
def setHorizontalScrollBarPolicy(self, policy):
|
64
|
+
super().setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
|
65
|
+
self.hScrollBar.setForceHidden(policy == Qt.ScrollBarAlwaysOff)
|
66
|
+
|
67
|
+
def setSmoothMode(self, mode):
|
68
|
+
""" set smooth mode
|
69
|
+
|
70
|
+
Parameters
|
71
|
+
----------
|
72
|
+
mode: SmoothMode
|
73
|
+
smooth scroll mode
|
74
|
+
"""
|
75
|
+
self.smoothScroll.setSmoothMode(mode)
|
76
|
+
|
77
|
+
def keyPressEvent(self, e):
|
78
|
+
if e.key() in [Qt.Key_Left, Qt.Key_Right]:
|
79
|
+
return
|
80
|
+
|
81
|
+
return super().keyPressEvent(e)
|
82
|
+
|
83
|
+
def wheelEvent(self, e: QWheelEvent):
|
84
|
+
if e.angleDelta().x() != 0:
|
85
|
+
return
|
86
|
+
|
87
|
+
self.smoothScroll.wheelEvent(e)
|
88
|
+
e.setAccepted(True)
|
89
|
+
|
90
|
+
def enableTransparentBackground(self):
|
91
|
+
self.setStyleSheet("QScrollArea{border: none; background: transparent}")
|
92
|
+
|
93
|
+
if self.widget():
|
94
|
+
self.widget().setStyleSheet("QWidget{background: transparent}")
|
95
|
+
|
96
|
+
|
97
|
+
class SmoothScrollArea(QScrollArea):
|
98
|
+
""" Smooth scroll area """
|
99
|
+
|
100
|
+
def __init__(self, parent=None):
|
101
|
+
super().__init__(parent)
|
102
|
+
self.delegate = SmoothScrollDelegate(self, True)
|
103
|
+
|
104
|
+
def setScrollAnimation(self, orient, duration, easing=QEasingCurve.OutCubic):
|
105
|
+
""" set scroll animation
|
106
|
+
|
107
|
+
Parameters
|
108
|
+
----------
|
109
|
+
orient: Orient
|
110
|
+
scroll orientation
|
111
|
+
|
112
|
+
duration: int
|
113
|
+
scroll duration
|
114
|
+
|
115
|
+
easing: QEasingCurve
|
116
|
+
animation type
|
117
|
+
"""
|
118
|
+
bar = self.delegate.hScrollBar if orient == Qt.Horizontal else self.delegate.vScrollBar
|
119
|
+
bar.setScrollAnimation(duration, easing)
|
120
|
+
|
121
|
+
def enableTransparentBackground(self):
|
122
|
+
self.setStyleSheet("QScrollArea{border: none; background: transparent}")
|
123
|
+
|
124
|
+
if self.widget():
|
125
|
+
self.widget().setStyleSheet("QWidget{background: transparent}")
|