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.
Files changed (107) hide show
  1. fastuiwidgets/__init__.py +12 -0
  2. fastuiwidgets/_rc/__init__.py +0 -0
  3. fastuiwidgets/_rc/resource.py +98835 -0
  4. fastuiwidgets/common/__init__.py +12 -0
  5. fastuiwidgets/common/animation.py +530 -0
  6. fastuiwidgets/common/auto_wrap.py +164 -0
  7. fastuiwidgets/common/color.py +95 -0
  8. fastuiwidgets/common/config.py +423 -0
  9. fastuiwidgets/common/exception_handler.py +31 -0
  10. fastuiwidgets/common/font.py +38 -0
  11. fastuiwidgets/common/icon.py +703 -0
  12. fastuiwidgets/common/image_utils.py +198 -0
  13. fastuiwidgets/common/overload.py +47 -0
  14. fastuiwidgets/common/router.py +133 -0
  15. fastuiwidgets/common/screen.py +25 -0
  16. fastuiwidgets/common/smooth_scroll.py +141 -0
  17. fastuiwidgets/common/style_sheet.py +512 -0
  18. fastuiwidgets/common/theme_listener.py +27 -0
  19. fastuiwidgets/common/translator.py +14 -0
  20. fastuiwidgets/components/__init__.py +6 -0
  21. fastuiwidgets/components/date_time/__init__.py +4 -0
  22. fastuiwidgets/components/date_time/calendar_picker.py +121 -0
  23. fastuiwidgets/components/date_time/calendar_view.py +671 -0
  24. fastuiwidgets/components/date_time/date_picker.py +245 -0
  25. fastuiwidgets/components/date_time/fast_calendar_view.py +487 -0
  26. fastuiwidgets/components/date_time/picker_base.py +632 -0
  27. fastuiwidgets/components/date_time/time_picker.py +223 -0
  28. fastuiwidgets/components/dialog_box/__init__.py +6 -0
  29. fastuiwidgets/components/dialog_box/color_dialog.py +414 -0
  30. fastuiwidgets/components/dialog_box/dialog.py +167 -0
  31. fastuiwidgets/components/dialog_box/folder_list_dialog.py +307 -0
  32. fastuiwidgets/components/dialog_box/mask_dialog_base.py +120 -0
  33. fastuiwidgets/components/dialog_box/message_box_base.py +92 -0
  34. fastuiwidgets/components/dialog_box/message_dialog.py +65 -0
  35. fastuiwidgets/components/layout/__init__.py +3 -0
  36. fastuiwidgets/components/layout/expand_layout.py +96 -0
  37. fastuiwidgets/components/layout/flow_layout.py +236 -0
  38. fastuiwidgets/components/layout/v_box_layout.py +41 -0
  39. fastuiwidgets/components/material/__init__.py +6 -0
  40. fastuiwidgets/components/material/acrylic_combo_box.py +96 -0
  41. fastuiwidgets/components/material/acrylic_flyout.py +105 -0
  42. fastuiwidgets/components/material/acrylic_line_edit.py +27 -0
  43. fastuiwidgets/components/material/acrylic_menu.py +204 -0
  44. fastuiwidgets/components/material/acrylic_tool_tip.py +39 -0
  45. fastuiwidgets/components/material/acrylic_widget.py +42 -0
  46. fastuiwidgets/components/navigation/__init__.py +9 -0
  47. fastuiwidgets/components/navigation/breadcrumb.py +350 -0
  48. fastuiwidgets/components/navigation/navigation_bar.py +416 -0
  49. fastuiwidgets/components/navigation/navigation_interface.py +268 -0
  50. fastuiwidgets/components/navigation/navigation_panel.py +657 -0
  51. fastuiwidgets/components/navigation/navigation_widget.py +686 -0
  52. fastuiwidgets/components/navigation/pivot.py +272 -0
  53. fastuiwidgets/components/navigation/segmented_widget.py +174 -0
  54. fastuiwidgets/components/settings/__init__.py +8 -0
  55. fastuiwidgets/components/settings/custom_color_setting_card.py +139 -0
  56. fastuiwidgets/components/settings/expand_setting_card.py +390 -0
  57. fastuiwidgets/components/settings/folder_list_setting_card.py +134 -0
  58. fastuiwidgets/components/settings/options_setting_card.py +86 -0
  59. fastuiwidgets/components/settings/setting_card.py +449 -0
  60. fastuiwidgets/components/settings/setting_card_group.py +48 -0
  61. fastuiwidgets/components/widgets/__init__.py +41 -0
  62. fastuiwidgets/components/widgets/acrylic_label.py +261 -0
  63. fastuiwidgets/components/widgets/button.py +1059 -0
  64. fastuiwidgets/components/widgets/card_widget.py +369 -0
  65. fastuiwidgets/components/widgets/check_box.py +203 -0
  66. fastuiwidgets/components/widgets/combo_box.py +556 -0
  67. fastuiwidgets/components/widgets/command_bar.py +636 -0
  68. fastuiwidgets/components/widgets/cycle_list_widget.py +251 -0
  69. fastuiwidgets/components/widgets/flip_view.py +430 -0
  70. fastuiwidgets/components/widgets/flyout.py +521 -0
  71. fastuiwidgets/components/widgets/frameless_window.py +49 -0
  72. fastuiwidgets/components/widgets/icon_widget.py +53 -0
  73. fastuiwidgets/components/widgets/info_badge.py +483 -0
  74. fastuiwidgets/components/widgets/info_bar.py +596 -0
  75. fastuiwidgets/components/widgets/label.py +553 -0
  76. fastuiwidgets/components/widgets/line_edit.py +551 -0
  77. fastuiwidgets/components/widgets/list_view.py +158 -0
  78. fastuiwidgets/components/widgets/menu.py +1318 -0
  79. fastuiwidgets/components/widgets/pips_pager.py +331 -0
  80. fastuiwidgets/components/widgets/progress_bar.py +311 -0
  81. fastuiwidgets/components/widgets/progress_ring.py +212 -0
  82. fastuiwidgets/components/widgets/scroll_area.py +125 -0
  83. fastuiwidgets/components/widgets/scroll_bar.py +673 -0
  84. fastuiwidgets/components/widgets/separator.py +43 -0
  85. fastuiwidgets/components/widgets/slider.py +307 -0
  86. fastuiwidgets/components/widgets/spin_box.py +306 -0
  87. fastuiwidgets/components/widgets/stacked_widget.py +211 -0
  88. fastuiwidgets/components/widgets/state_tool_tip.py +188 -0
  89. fastuiwidgets/components/widgets/switch_button.py +312 -0
  90. fastuiwidgets/components/widgets/tab_view.py +804 -0
  91. fastuiwidgets/components/widgets/table_view.py +360 -0
  92. fastuiwidgets/components/widgets/teaching_tip.py +657 -0
  93. fastuiwidgets/components/widgets/tool_tip.py +460 -0
  94. fastuiwidgets/components/widgets/tree_view.py +216 -0
  95. fastuiwidgets/multimedia/__init__.py +3 -0
  96. fastuiwidgets/multimedia/media_play_bar.py +319 -0
  97. fastuiwidgets/multimedia/media_player.py +124 -0
  98. fastuiwidgets/multimedia/video_widget.py +93 -0
  99. fastuiwidgets/window/__init__.py +2 -0
  100. fastuiwidgets/window/fluent_window.py +413 -0
  101. fastuiwidgets/window/splash_screen.py +92 -0
  102. fastuiwidgets/window/stacked_widget.py +66 -0
  103. python_fastui_widgets-1.0.0.dist-info/METADATA +30 -0
  104. python_fastui_widgets-1.0.0.dist-info/RECORD +107 -0
  105. python_fastui_widgets-1.0.0.dist-info/WHEEL +5 -0
  106. python_fastui_widgets-1.0.0.dist-info/licenses/LICENSE +674 -0
  107. python_fastui_widgets-1.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,245 @@
1
+ # coding:utf-8
2
+ from PySide6.QtCore import Qt, Signal, QDate, QCalendar, Property
3
+
4
+ from .picker_base import PickerBase, PickerPanel, PickerColumnFormatter, DigitFormatter
5
+
6
+
7
+ class DatePickerBase(PickerBase):
8
+ """ Date picker base class """
9
+
10
+ dateChanged = Signal(QDate)
11
+
12
+ def __init__(self, parent=None):
13
+ super().__init__(parent)
14
+ self._date = QDate()
15
+ self.calendar = QCalendar()
16
+ self._yearFormatter = None
17
+ self._monthFormatter = None
18
+ self._dayFormatter = None
19
+
20
+ def getDate(self):
21
+ return self._date
22
+
23
+ def setDate(self, date: QDate):
24
+ """ set current date """
25
+ raise NotImplementedError
26
+
27
+ def setYearFormatter(self, formatter: PickerColumnFormatter):
28
+ self._yearFormatter = formatter
29
+
30
+ def setMonthFormatter(self, formatter: PickerColumnFormatter):
31
+ self._monthFormatter = formatter
32
+
33
+ def setDayFormatter(self, formatter: PickerColumnFormatter):
34
+ self._dayFormatter = formatter
35
+
36
+ def yearFormatter(self):
37
+ return self._yearFormatter or DigitFormatter()
38
+
39
+ def dayFormatter(self):
40
+ return self._dayFormatter or DigitFormatter()
41
+
42
+ def monthFormatter(self):
43
+ return self._monthFormatter or MonthFormatter()
44
+
45
+
46
+ class MonthFormatter(PickerColumnFormatter):
47
+ """ Month formatter """
48
+
49
+ def __init__(self):
50
+ super().__init__()
51
+ self.months = [
52
+ self.tr('January'), self.tr('February'), self.tr('March'),
53
+ self.tr('April'), self.tr('May'), self.tr('June'),
54
+ self.tr('July'), self.tr('August'), self.tr('September'),
55
+ self.tr('October'), self.tr('November'), self.tr('December')
56
+ ]
57
+
58
+ def encode(self, month):
59
+ return self.months[int(month) - 1]
60
+
61
+ def decode(self, value):
62
+ return self.months.index(value) + 1
63
+
64
+
65
+ class DatePicker(DatePickerBase):
66
+ """ Date picker """
67
+
68
+ MM_DD_YYYY = 0
69
+ YYYY_MM_DD = 1
70
+
71
+ def __init__(self, parent=None, format=MM_DD_YYYY, isMonthTight=True):
72
+ """
73
+ Parameters
74
+ ----------
75
+ parent: QWidget
76
+ parent widget
77
+
78
+ format: int
79
+ the format of date, could be `DatePicker.MM_DD_YYYY` or `DatePicker.YYYY_MM_DD`
80
+
81
+ isMonthTight: bool
82
+ is the month column tight
83
+ """
84
+ super().__init__(parent=parent)
85
+ self.MONTH = self.tr('month')
86
+ self.YEAR = self.tr('year')
87
+ self.DAY = self.tr('day')
88
+
89
+ self.isMonthTight = isMonthTight
90
+ self.setDateFormat(format)
91
+
92
+ def setDateFormat(self, format: int):
93
+ """ set the format of date
94
+
95
+ Parameters
96
+ ----------
97
+ format: int
98
+ the format of date, could be `DatePicker.MM_DD_YYYY` or `DatePicker.YYYY_MM_DD`
99
+ """
100
+ self.clearColumns()
101
+ y = QDate.currentDate().year()
102
+ self.dateFormat = format
103
+
104
+ if format == self.MM_DD_YYYY:
105
+ self.monthIndex = 0
106
+ self.dayIndex = 1
107
+ self.yearIndex = 2
108
+
109
+ self.addColumn(self.MONTH, range(1, 13),
110
+ 80, Qt.AlignLeft, self.monthFormatter())
111
+ self.addColumn(self.DAY, range(1, 32),
112
+ 80, formatter=self.dayFormatter())
113
+ self.addColumn(self.YEAR, range(y-100, y+101),
114
+ 80, formatter=self.yearFormatter())
115
+ elif format == self.YYYY_MM_DD:
116
+ self.yearIndex = 0
117
+ self.monthIndex = 1
118
+ self.dayIndex = 2
119
+
120
+ self.addColumn(self.YEAR, range(y-100, y+101),
121
+ 80, formatter=self.yearFormatter())
122
+ self.addColumn(self.MONTH, range(1, 13),
123
+ 80, formatter=self.monthFormatter())
124
+ self.addColumn(self.DAY, range(1, 32), 80,
125
+ formatter=self.dayFormatter())
126
+
127
+ self.setColumnWidth(self.monthIndex, self._monthColumnWidth())
128
+
129
+ def panelInitialValue(self):
130
+ if any(self.value()):
131
+ return self.value()
132
+
133
+ date = QDate.currentDate()
134
+ y = self.encodeValue(self.yearIndex, date.year())
135
+ m = self.encodeValue(self.monthIndex, date.month())
136
+ d = self.encodeValue(self.dayIndex, date.day())
137
+ return [y, m, d] if self.dateFormat == self.YYYY_MM_DD else [m, d, y]
138
+
139
+ def setMonthTight(self, isTight: bool):
140
+ """ set whether the month column is tight """
141
+ if self.isMonthTight == isTight:
142
+ return
143
+
144
+ self.isMonthTight = isTight
145
+ self.setColumnWidth(self.monthIndex, self._monthColumnWidth())
146
+
147
+ def _monthColumnWidth(self):
148
+ fm = self.fontMetrics()
149
+ wm = max(fm.boundingRect(i).width()
150
+ for i in self.columns[self.monthIndex].items()) + 20
151
+
152
+ # don't use tight layout for english
153
+ if self.MONTH == 'month':
154
+ return wm + 49
155
+
156
+ return max(80, wm) if self.isMonthTight else wm + 49
157
+
158
+ def _onColumnValueChanged(self, panel: PickerPanel, index, value):
159
+ if index == self.dayIndex:
160
+ return
161
+
162
+ # get days number in month
163
+ month = self.decodeValue(
164
+ self.monthIndex, panel.columnValue(self.monthIndex))
165
+ year = self.decodeValue(
166
+ self.yearIndex, panel.columnValue(self.yearIndex))
167
+ days = self.calendar.daysInMonth(month, year)
168
+
169
+ # update days
170
+ c = panel.column(self.dayIndex)
171
+ day = c.currentItem().text()
172
+ self.setColumnItems(self.dayIndex, range(1, days + 1))
173
+
174
+ c.setItems(self.columns[self.dayIndex].items())
175
+ c.setSelectedItem(day)
176
+
177
+ def _onConfirmed(self, value: list):
178
+ year = self.decodeValue(self.yearIndex, value[self.yearIndex])
179
+ month = self.decodeValue(self.monthIndex, value[self.monthIndex])
180
+ day = self.decodeValue(self.dayIndex, value[self.dayIndex])
181
+
182
+ date, od = QDate(year, month, day), self.date
183
+ self.setDate(date)
184
+
185
+ if od != date:
186
+ self.dateChanged.emit(date)
187
+
188
+ def getDate(self):
189
+ return self._date
190
+
191
+ def setDate(self, date: QDate):
192
+ if not date.isValid() or date.isNull():
193
+ return
194
+
195
+ self._date = date
196
+ self.setColumnValue(self.monthIndex, date.month())
197
+ self.setColumnValue(self.dayIndex, date.day())
198
+ self.setColumnValue(self.yearIndex, date.year())
199
+ self.setColumnItems(self.dayIndex, range(1, date.daysInMonth() + 1))
200
+
201
+ date = Property(QDate, getDate, setDate)
202
+
203
+
204
+ class ZhFormatter(PickerColumnFormatter):
205
+ """ Chinese date formatter """
206
+
207
+ suffix = ""
208
+
209
+ def encode(self, value):
210
+ return str(value) + self.suffix
211
+
212
+ def decode(self, value: str):
213
+ return int(value[:-1])
214
+
215
+
216
+ class ZhYearFormatter(ZhFormatter):
217
+ """ Chinese year formatter """
218
+
219
+ suffix = "年"
220
+
221
+
222
+ class ZhMonthFormatter(ZhFormatter):
223
+ """ Chinese month formatter """
224
+
225
+ suffix = "月"
226
+
227
+
228
+ class ZhDayFormatter(ZhFormatter):
229
+ """ Chinese day formatter """
230
+
231
+ suffix = "日"
232
+
233
+
234
+ class ZhDatePicker(DatePicker):
235
+ """ Chinese date picker """
236
+
237
+ def __init__(self, parent=None):
238
+ super().__init__(parent, DatePicker.YYYY_MM_DD)
239
+ self.MONTH = "月"
240
+ self.YEAR = "年"
241
+ self.DAY = "日"
242
+ self.setDayFormatter(ZhDayFormatter())
243
+ self.setYearFormatter(ZhYearFormatter())
244
+ self.setMonthFormatter(ZhMonthFormatter())
245
+ self.setDateFormat(self.YYYY_MM_DD)