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,261 @@
|
|
1
|
+
# coding:utf-8
|
2
|
+
import warnings
|
3
|
+
from typing import Union
|
4
|
+
|
5
|
+
from PySide6.QtCore import Qt, QThread, Signal, QRect
|
6
|
+
from PySide6.QtGui import QBrush, QColor, QImage, QPainter, QPixmap, QPainterPath
|
7
|
+
from PySide6.QtWidgets import QLabel, QApplication, QWidget
|
8
|
+
|
9
|
+
from ...common.screen import getCurrentScreen
|
10
|
+
|
11
|
+
try:
|
12
|
+
from ...common.image_utils import gaussianBlur
|
13
|
+
|
14
|
+
isAcrylicAvailable = True
|
15
|
+
except ImportError as e:
|
16
|
+
isAcrylicAvailable = False
|
17
|
+
|
18
|
+
def gaussianBlur(imagePath, blurRadius=18, brightFactor=1, blurPicSize=None):
|
19
|
+
return QPixmap(imagePath)
|
20
|
+
|
21
|
+
|
22
|
+
def checkAcrylicAvailability():
|
23
|
+
if not isAcrylicAvailable:
|
24
|
+
warnings.warn(
|
25
|
+
'Acrylic is not supported in current fastuiwidgets, use `pip install Python-FastUI-Widgets[full]` to enable it.')
|
26
|
+
|
27
|
+
return isAcrylicAvailable
|
28
|
+
|
29
|
+
|
30
|
+
class BlurCoverThread(QThread):
|
31
|
+
""" Blur album cover thread """
|
32
|
+
|
33
|
+
blurFinished = Signal(QPixmap)
|
34
|
+
|
35
|
+
def __init__(self, parent=None):
|
36
|
+
super().__init__(parent)
|
37
|
+
self.imagePath = ""
|
38
|
+
self.blurRadius = 7
|
39
|
+
self.maxSize = None
|
40
|
+
|
41
|
+
def run(self):
|
42
|
+
if not self.imagePath:
|
43
|
+
return
|
44
|
+
|
45
|
+
pixmap = gaussianBlur(
|
46
|
+
self.imagePath, self.blurRadius, 0.85, self.maxSize)
|
47
|
+
self.blurFinished.emit(pixmap)
|
48
|
+
|
49
|
+
def blur(self, imagePath: str, blurRadius=6, maxSize: tuple = (450, 450)):
|
50
|
+
self.imagePath = imagePath
|
51
|
+
self.blurRadius = blurRadius
|
52
|
+
self.maxSize = maxSize or self.maxSize
|
53
|
+
self.start()
|
54
|
+
|
55
|
+
|
56
|
+
class AcrylicTextureLabel(QLabel):
|
57
|
+
""" Acrylic texture label """
|
58
|
+
|
59
|
+
def __init__(self, tintColor: QColor, luminosityColor: QColor, noiseOpacity=0.03, parent=None):
|
60
|
+
"""
|
61
|
+
Parameters
|
62
|
+
----------
|
63
|
+
tintColor: QColor
|
64
|
+
RGB tint color
|
65
|
+
|
66
|
+
luminosityColor: QColor
|
67
|
+
luminosity layer color
|
68
|
+
|
69
|
+
noiseOpacity: float
|
70
|
+
noise layer opacity
|
71
|
+
|
72
|
+
parent:
|
73
|
+
parent window
|
74
|
+
"""
|
75
|
+
super().__init__(parent=parent)
|
76
|
+
self.tintColor = QColor(tintColor)
|
77
|
+
self.luminosityColor = QColor(luminosityColor)
|
78
|
+
self.noiseOpacity = noiseOpacity
|
79
|
+
self.noiseImage = QImage(':/fastuiwidgets/images/acrylic/noise.png')
|
80
|
+
self.setAttribute(Qt.WA_TranslucentBackground)
|
81
|
+
|
82
|
+
def setTintColor(self, color: QColor):
|
83
|
+
self.tintColor = color
|
84
|
+
self.update()
|
85
|
+
|
86
|
+
def paintEvent(self, e):
|
87
|
+
acrylicTexture = QImage(64, 64, QImage.Format_ARGB32_Premultiplied)
|
88
|
+
|
89
|
+
# paint luminosity layer
|
90
|
+
acrylicTexture.fill(self.luminosityColor)
|
91
|
+
|
92
|
+
# paint tint color
|
93
|
+
painter = QPainter(acrylicTexture)
|
94
|
+
painter.fillRect(acrylicTexture.rect(), self.tintColor)
|
95
|
+
|
96
|
+
# paint noise
|
97
|
+
painter.setOpacity(self.noiseOpacity)
|
98
|
+
painter.drawImage(acrylicTexture.rect(), self.noiseImage)
|
99
|
+
|
100
|
+
acrylicBrush = QBrush(acrylicTexture)
|
101
|
+
painter = QPainter(self)
|
102
|
+
painter.fillRect(self.rect(), acrylicBrush)
|
103
|
+
|
104
|
+
|
105
|
+
class AcrylicLabel(QLabel):
|
106
|
+
""" Acrylic label """
|
107
|
+
|
108
|
+
def __init__(self, blurRadius: int, tintColor: QColor, luminosityColor=QColor(255, 255, 255, 0),
|
109
|
+
maxBlurSize: tuple = None, parent=None):
|
110
|
+
"""
|
111
|
+
Parameters
|
112
|
+
----------
|
113
|
+
blurRadius: int
|
114
|
+
blur radius
|
115
|
+
|
116
|
+
tintColor: QColor
|
117
|
+
tint color
|
118
|
+
|
119
|
+
luminosityColor: QColor
|
120
|
+
luminosity layer color
|
121
|
+
|
122
|
+
maxBlurSize: tuple
|
123
|
+
maximum image size
|
124
|
+
|
125
|
+
parent:
|
126
|
+
parent window
|
127
|
+
"""
|
128
|
+
super().__init__(parent=parent)
|
129
|
+
checkAcrylicAvailability()
|
130
|
+
|
131
|
+
self.imagePath = ''
|
132
|
+
self.blurPixmap = QPixmap()
|
133
|
+
self.blurRadius = blurRadius
|
134
|
+
self.maxBlurSize = maxBlurSize
|
135
|
+
self.acrylicTextureLabel = AcrylicTextureLabel(
|
136
|
+
tintColor, luminosityColor, parent=self)
|
137
|
+
self.blurThread = BlurCoverThread(self)
|
138
|
+
self.blurThread.blurFinished.connect(self.__onBlurFinished)
|
139
|
+
|
140
|
+
def __onBlurFinished(self, blurPixmap: QPixmap):
|
141
|
+
""" blur finished slot """
|
142
|
+
self.blurPixmap = blurPixmap
|
143
|
+
self.setPixmap(self.blurPixmap)
|
144
|
+
self.adjustSize()
|
145
|
+
|
146
|
+
def setImage(self, imagePath: str):
|
147
|
+
""" set the image to be blurred """
|
148
|
+
self.imagePath = imagePath
|
149
|
+
self.blurThread.blur(imagePath, self.blurRadius, self.maxBlurSize)
|
150
|
+
|
151
|
+
def setTintColor(self, color: QColor):
|
152
|
+
self.acrylicTextureLabel.setTintColor(color)
|
153
|
+
|
154
|
+
def resizeEvent(self, e):
|
155
|
+
super().resizeEvent(e)
|
156
|
+
self.acrylicTextureLabel.resize(self.size())
|
157
|
+
|
158
|
+
if not self.blurPixmap.isNull() and self.blurPixmap.size() != self.size():
|
159
|
+
self.setPixmap(self.blurPixmap.scaled(
|
160
|
+
self.size(), Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation))
|
161
|
+
|
162
|
+
|
163
|
+
class AcrylicBrush:
|
164
|
+
""" Acrylic brush """
|
165
|
+
|
166
|
+
def __init__(self, device: QWidget, blurRadius: int, tintColor=QColor(242, 242, 242, 150),
|
167
|
+
luminosityColor=QColor(255, 255, 255, 10), noiseOpacity=0.03):
|
168
|
+
self.device = device
|
169
|
+
self.blurRadius = blurRadius
|
170
|
+
self.tintColor = QColor(tintColor)
|
171
|
+
self.luminosityColor = QColor(luminosityColor)
|
172
|
+
self.noiseOpacity = noiseOpacity
|
173
|
+
self.noiseImage = QImage(':/fastuiwidgets/images/acrylic/noise.png')
|
174
|
+
self.originalImage = QPixmap()
|
175
|
+
self.image = QPixmap()
|
176
|
+
|
177
|
+
self.clipPath = QPainterPath()
|
178
|
+
|
179
|
+
def setBlurRadius(self, radius: int):
|
180
|
+
if radius == self.blurRadius:
|
181
|
+
return
|
182
|
+
|
183
|
+
self.blurRadius = radius
|
184
|
+
self.setImage(self.originalImage)
|
185
|
+
|
186
|
+
def setTintColor(self, color: QColor):
|
187
|
+
self.tintColor = QColor(color)
|
188
|
+
self.device.update()
|
189
|
+
|
190
|
+
def setLuminosityColor(self, color: QColor):
|
191
|
+
self.luminosityColor = QColor(color)
|
192
|
+
self.device.update()
|
193
|
+
|
194
|
+
def isAvailable(self):
|
195
|
+
return isAcrylicAvailable
|
196
|
+
|
197
|
+
def grabImage(self, rect: QRect):
|
198
|
+
""" grab image from screen
|
199
|
+
|
200
|
+
Parameters
|
201
|
+
----------
|
202
|
+
rect: QRect
|
203
|
+
grabbed region
|
204
|
+
"""
|
205
|
+
screen = getCurrentScreen()
|
206
|
+
if not screen:
|
207
|
+
screen = QApplication.screens()[0]
|
208
|
+
|
209
|
+
x, y, w, h = rect.x(), rect.y(), rect.width(), rect.height()
|
210
|
+
x -= screen.geometry().x()
|
211
|
+
y -= screen.geometry().y()
|
212
|
+
self.setImage(screen.grabWindow(0, x, y, w, h))
|
213
|
+
|
214
|
+
def setImage(self, image: Union[str, QImage, QPixmap]):
|
215
|
+
""" set blurred image """
|
216
|
+
if isinstance(image, str):
|
217
|
+
image = QPixmap(image)
|
218
|
+
elif isinstance(image, QImage):
|
219
|
+
image = QPixmap.fromImage(image)
|
220
|
+
|
221
|
+
self.originalImage = image
|
222
|
+
if not image.isNull():
|
223
|
+
checkAcrylicAvailability()
|
224
|
+
|
225
|
+
self.image = gaussianBlur(image, self.blurRadius)
|
226
|
+
|
227
|
+
self.device.update()
|
228
|
+
|
229
|
+
def setClipPath(self, path: QPainterPath):
|
230
|
+
self.clipPath = path
|
231
|
+
self.device.update()
|
232
|
+
|
233
|
+
def textureImage(self):
|
234
|
+
texture = QImage(64, 64, QImage.Format_ARGB32_Premultiplied)
|
235
|
+
texture.fill(self.luminosityColor)
|
236
|
+
|
237
|
+
# paint tint color
|
238
|
+
painter = QPainter(texture)
|
239
|
+
painter.fillRect(texture.rect(), self.tintColor)
|
240
|
+
|
241
|
+
# paint noise
|
242
|
+
painter.setOpacity(self.noiseOpacity)
|
243
|
+
painter.drawImage(texture.rect(), self.noiseImage)
|
244
|
+
|
245
|
+
return texture
|
246
|
+
|
247
|
+
def paint(self):
|
248
|
+
device = self.device
|
249
|
+
|
250
|
+
painter = QPainter(device)
|
251
|
+
painter.setRenderHints(QPainter.Antialiasing)
|
252
|
+
|
253
|
+
if not self.clipPath.isEmpty():
|
254
|
+
painter.setClipPath(self.clipPath)
|
255
|
+
|
256
|
+
# paint image
|
257
|
+
image = self.image.scaled(device.size(), Qt.KeepAspectRatioByExpanding, Qt.SmoothTransformation)
|
258
|
+
painter.drawPixmap(0, 0, image)
|
259
|
+
|
260
|
+
# paint acrylic texture
|
261
|
+
painter.fillRect(device.rect(), QBrush(self.textureImage()))
|