flet 0.70.0.dev5774__py3-none-any.whl → 0.70.0.dev5835__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.
Potentially problematic release.
This version of flet might be problematic. Click here for more details.
- flet/__init__.py +32 -4
- flet/components/__init__.py +0 -0
- flet/components/component.py +346 -0
- flet/components/component_decorator.py +24 -0
- flet/components/component_owned.py +22 -0
- flet/components/hooks/__init__.py +0 -0
- flet/components/hooks/hook.py +12 -0
- flet/components/hooks/use_callback.py +28 -0
- flet/components/hooks/use_context.py +91 -0
- flet/components/hooks/use_effect.py +104 -0
- flet/components/hooks/use_memo.py +52 -0
- flet/components/hooks/use_state.py +58 -0
- flet/components/memo.py +34 -0
- flet/components/observable.py +269 -0
- flet/components/public_utils.py +10 -0
- flet/components/utils.py +85 -0
- flet/controls/base_control.py +34 -10
- flet/controls/base_page.py +44 -40
- flet/controls/context.py +22 -1
- flet/controls/control.py +12 -6
- flet/controls/control_event.py +19 -2
- flet/controls/core/animated_switcher.py +3 -2
- flet/controls/core/autofill_group.py +6 -2
- flet/controls/core/column.py +5 -0
- flet/controls/core/dismissible.py +12 -10
- flet/controls/core/drag_target.py +20 -10
- flet/controls/core/draggable.py +9 -9
- flet/controls/core/icon.py +16 -12
- flet/controls/core/interactive_viewer.py +24 -23
- flet/controls/core/pagelet.py +3 -2
- flet/controls/core/reorderable_draggable.py +3 -2
- flet/controls/core/row.py +5 -0
- flet/controls/core/safe_area.py +3 -2
- flet/controls/core/text_span.py +5 -3
- flet/controls/core/view.py +6 -6
- flet/controls/core/window_drag_area.py +3 -2
- flet/controls/cupertino/cupertino_action_sheet.py +10 -5
- flet/controls/cupertino/cupertino_action_sheet_action.py +3 -4
- flet/controls/cupertino/cupertino_activity_indicator.py +4 -3
- flet/controls/cupertino/cupertino_alert_dialog.py +6 -3
- flet/controls/cupertino/cupertino_button.py +6 -5
- flet/controls/cupertino/cupertino_context_menu.py +8 -4
- flet/controls/cupertino/cupertino_context_menu_action.py +3 -4
- flet/controls/cupertino/cupertino_date_picker.py +44 -28
- flet/controls/cupertino/cupertino_dialog_action.py +3 -4
- flet/controls/cupertino/cupertino_list_tile.py +3 -4
- flet/controls/cupertino/cupertino_navigation_bar.py +6 -5
- flet/controls/cupertino/cupertino_picker.py +14 -10
- flet/controls/cupertino/cupertino_segmented_button.py +6 -5
- flet/controls/cupertino/cupertino_slider.py +16 -12
- flet/controls/cupertino/cupertino_sliding_segmented_button.py +6 -5
- flet/controls/cupertino/cupertino_timer_picker.py +38 -31
- flet/controls/id_counter.py +24 -0
- flet/controls/material/alert_dialog.py +6 -5
- flet/controls/material/app_bar.py +17 -14
- flet/controls/material/banner.py +13 -11
- flet/controls/material/bottom_app_bar.py +5 -4
- flet/controls/material/bottom_sheet.py +5 -4
- flet/controls/material/button.py +12 -4
- flet/controls/material/chip.py +13 -12
- flet/controls/material/circle_avatar.py +17 -13
- flet/controls/material/datatable.py +48 -41
- flet/controls/material/divider.py +30 -14
- flet/controls/material/dropdown.py +5 -3
- flet/controls/material/expansion_tile.py +11 -22
- flet/controls/material/floating_action_button.py +32 -23
- flet/controls/material/icon_button.py +7 -3
- flet/controls/material/navigation_rail.py +14 -11
- flet/controls/material/outlined_button.py +7 -3
- flet/controls/material/progress_bar.py +18 -10
- flet/controls/material/radio_group.py +5 -1
- flet/controls/material/range_slider.py +13 -13
- flet/controls/material/segmented_button.py +21 -17
- flet/controls/material/selection_area.py +3 -2
- flet/controls/material/slider.py +16 -12
- flet/controls/material/snack_bar.py +18 -10
- flet/controls/material/switch.py +6 -5
- flet/controls/material/tabs.py +18 -14
- flet/controls/material/textfield.py +32 -15
- flet/controls/material/vertical_divider.py +20 -12
- flet/controls/object_patch.py +434 -197
- flet/controls/page.py +205 -85
- flet/controls/services/haptic_feedback.py +0 -3
- flet/controls/services/shake_detector.py +0 -3
- flet/messaging/flet_socket_server.py +13 -6
- flet/messaging/session.py +103 -10
- flet/{controls/session_storage.py → messaging/session_store.py} +2 -2
- flet/version.py +1 -1
- {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/METADATA +5 -5
- {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/RECORD +93 -80
- flet/controls/cache.py +0 -87
- flet/controls/control_id.py +0 -22
- flet/controls/core/state_view.py +0 -60
- {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/WHEEL +0 -0
- {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/entry_points.txt +0 -0
- {flet-0.70.0.dev5774.dist-info → flet-0.70.0.dev5835.dist-info}/top_level.txt +0 -0
|
@@ -33,6 +33,9 @@ class ExpansionTile(LayoutControl, AdaptiveControl):
|
|
|
33
33
|
"""
|
|
34
34
|
A single-line ListTile with an expansion arrow icon that expands or collapses the
|
|
35
35
|
tile to reveal or hide its controls.
|
|
36
|
+
|
|
37
|
+
Raises:
|
|
38
|
+
ValueError: If [`title`][(c).] is neither a string nor a visible Control.
|
|
36
39
|
"""
|
|
37
40
|
|
|
38
41
|
title: StrOrControl
|
|
@@ -108,28 +111,22 @@ class ExpansionTile(LayoutControl, AdaptiveControl):
|
|
|
108
111
|
initially_expanded: bool = False
|
|
109
112
|
"""
|
|
110
113
|
A boolean value which defines whether the tile is initially expanded or collapsed.
|
|
111
|
-
|
|
112
|
-
Defaults to `False`.
|
|
113
114
|
"""
|
|
114
115
|
|
|
115
116
|
maintain_state: bool = False
|
|
116
117
|
"""
|
|
117
118
|
A boolean value which defines whether the state of the `controls` is maintained
|
|
118
119
|
when the tile expands and collapses.
|
|
119
|
-
|
|
120
|
-
Defaults to `False`.
|
|
121
120
|
"""
|
|
122
121
|
|
|
123
122
|
text_color: Optional[ColorValue] = None
|
|
124
123
|
"""
|
|
125
|
-
The color of the tile's titles when the
|
|
126
|
-
sublist is expanded.
|
|
124
|
+
The color of the tile's titles when the sublist is expanded.
|
|
127
125
|
"""
|
|
128
126
|
|
|
129
127
|
icon_color: Optional[ColorValue] = None
|
|
130
128
|
"""
|
|
131
|
-
The icon color of tile's expansion arrow
|
|
132
|
-
icon when the sublist is expanded.
|
|
129
|
+
The icon color of tile's expansion arrow icon when the sublist is expanded.
|
|
133
130
|
"""
|
|
134
131
|
|
|
135
132
|
shape: Optional[OutlinedBorder] = None
|
|
@@ -139,26 +136,22 @@ class ExpansionTile(LayoutControl, AdaptiveControl):
|
|
|
139
136
|
|
|
140
137
|
bgcolor: Optional[ColorValue] = None
|
|
141
138
|
"""
|
|
142
|
-
The color to display behind the sublist
|
|
143
|
-
when expanded.
|
|
139
|
+
The color to display behind the sublist when expanded.
|
|
144
140
|
"""
|
|
145
141
|
|
|
146
142
|
collapsed_bgcolor: Optional[ColorValue] = None
|
|
147
143
|
"""
|
|
148
|
-
Defines the background color of tile when
|
|
149
|
-
the sublist is collapsed.
|
|
144
|
+
Defines the background color of tile when the sublist is collapsed.
|
|
150
145
|
"""
|
|
151
146
|
|
|
152
147
|
collapsed_icon_color: Optional[ColorValue] = None
|
|
153
148
|
"""
|
|
154
|
-
The icon color of tile's expansion arrow
|
|
155
|
-
icon when the sublist is collapsed.
|
|
149
|
+
The icon color of tile's expansion arrow icon when the sublist is collapsed.
|
|
156
150
|
"""
|
|
157
151
|
|
|
158
152
|
collapsed_text_color: Optional[ColorValue] = None
|
|
159
153
|
"""
|
|
160
|
-
The color of the tile's titles when the
|
|
161
|
-
sublist is collapsed.
|
|
154
|
+
The color of the tile's titles when the sublist is collapsed.
|
|
162
155
|
"""
|
|
163
156
|
|
|
164
157
|
collapsed_shape: Optional[OutlinedBorder] = None
|
|
@@ -179,16 +172,12 @@ class ExpansionTile(LayoutControl, AdaptiveControl):
|
|
|
179
172
|
Whether detected gestures should provide acoustic and/or haptic feedback. For
|
|
180
173
|
example, on Android a tap will produce a clicking sound and a long-press will
|
|
181
174
|
produce a short vibration, when feedback is enabled.
|
|
182
|
-
|
|
183
|
-
Defaults to `True`.
|
|
184
175
|
"""
|
|
185
176
|
|
|
186
177
|
show_trailing_icon: bool = True
|
|
187
178
|
"""
|
|
188
179
|
Whether to show the trailing icon (be it the default icon or the custom `trailing`,
|
|
189
180
|
if specified and visible).
|
|
190
|
-
|
|
191
|
-
Defaults to `True`.
|
|
192
181
|
"""
|
|
193
182
|
|
|
194
183
|
min_tile_height: Optional[Number] = None
|
|
@@ -208,5 +197,5 @@ class ExpansionTile(LayoutControl, AdaptiveControl):
|
|
|
208
197
|
|
|
209
198
|
def before_update(self):
|
|
210
199
|
super().before_update()
|
|
211
|
-
if isinstance(self.title, Control):
|
|
212
|
-
|
|
200
|
+
if isinstance(self.title, Control) and not self.title.visible:
|
|
201
|
+
raise ValueError("title must be visible")
|
|
@@ -27,9 +27,9 @@ class FloatingActionButton(LayoutControl):
|
|
|
27
27
|
place on a page.
|
|
28
28
|
|
|
29
29
|
Raises:
|
|
30
|
-
|
|
30
|
+
ValueError: If neither [`icon`][(c).] nor a valid [`content`][(c).]
|
|
31
31
|
(string or visible Control) is provided.
|
|
32
|
-
|
|
32
|
+
ValueError: If [`elevation`][(c).],
|
|
33
33
|
[`disabled_elevation`][(c).], [`focus_elevation`][(c).],
|
|
34
34
|
[`highlight_elevation`][(c).], or [`hover_elevation`][(c).]
|
|
35
35
|
is negative.
|
|
@@ -161,27 +161,36 @@ class FloatingActionButton(LayoutControl):
|
|
|
161
161
|
|
|
162
162
|
def before_update(self):
|
|
163
163
|
super().before_update()
|
|
164
|
-
|
|
164
|
+
if not (
|
|
165
165
|
self.icon
|
|
166
166
|
or isinstance(self.content, str)
|
|
167
167
|
or (isinstance(self.content, Control) and self.content.visible)
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
168
|
+
):
|
|
169
|
+
raise ValueError(
|
|
170
|
+
"at minimum, icon or a content (string or visible Control) "
|
|
171
|
+
"must be provided"
|
|
172
|
+
)
|
|
173
|
+
if self.elevation is not None and self.elevation < 0:
|
|
174
|
+
raise ValueError(
|
|
175
|
+
f"elevation must be greater than or equal to 0, got {self.elevation}"
|
|
176
|
+
)
|
|
177
|
+
if self.disabled_elevation is not None and self.disabled_elevation < 0:
|
|
178
|
+
raise ValueError(
|
|
179
|
+
"disabled_elevation must be greater than or equal to 0, "
|
|
180
|
+
f"got {self.disabled_elevation}"
|
|
181
|
+
)
|
|
182
|
+
if self.focus_elevation is not None and self.focus_elevation < 0:
|
|
183
|
+
raise ValueError(
|
|
184
|
+
"focus_elevation must be greater than or equal to 0, "
|
|
185
|
+
f"got {self.focus_elevation}"
|
|
186
|
+
)
|
|
187
|
+
if self.highlight_elevation is not None and self.highlight_elevation < 0:
|
|
188
|
+
raise ValueError(
|
|
189
|
+
"highlight_elevation must be greater than or equal to 0, "
|
|
190
|
+
f"got {self.highlight_elevation}"
|
|
191
|
+
)
|
|
192
|
+
if self.hover_elevation is not None and self.hover_elevation < 0:
|
|
193
|
+
raise ValueError(
|
|
194
|
+
"hover_elevation must be greater than or equal to 0, "
|
|
195
|
+
f"got {self.hover_elevation}"
|
|
196
|
+
)
|
|
@@ -34,6 +34,9 @@ class IconButton(LayoutControl, AdaptiveControl):
|
|
|
34
34
|
|
|
35
35
|
Icon buttons are commonly used in the toolbars, but they can be used in many other
|
|
36
36
|
places as well.
|
|
37
|
+
|
|
38
|
+
Raises:
|
|
39
|
+
ValueError: If [`splash_radius`][(c).] is not greater than `0`.
|
|
37
40
|
"""
|
|
38
41
|
|
|
39
42
|
icon: Optional[IconDataOrControl] = None
|
|
@@ -200,9 +203,10 @@ class IconButton(LayoutControl, AdaptiveControl):
|
|
|
200
203
|
|
|
201
204
|
def before_update(self):
|
|
202
205
|
super().before_update()
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
if self.splash_radius is not None and self.splash_radius <= 0:
|
|
207
|
+
raise ValueError(
|
|
208
|
+
f"splash_radius must be greater than 0, got {self.splash_radius}"
|
|
209
|
+
)
|
|
206
210
|
if (
|
|
207
211
|
self.style is not None
|
|
208
212
|
or self.bgcolor is not None
|
|
@@ -28,7 +28,7 @@ class NavigationRailLabelType(Enum):
|
|
|
28
28
|
@control("NavigationRailDestination")
|
|
29
29
|
class NavigationRailDestination(Control):
|
|
30
30
|
"""
|
|
31
|
-
|
|
31
|
+
Represents a destination in a `NavigationRail`.
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
34
|
icon: Optional[IconDataOrControl] = None
|
|
@@ -81,6 +81,11 @@ class NavigationRail(LayoutControl):
|
|
|
81
81
|
"""
|
|
82
82
|
A material widget that is meant to be displayed at the left or right of an app to
|
|
83
83
|
navigate between a small number of views, typically between three and five.
|
|
84
|
+
|
|
85
|
+
Raises:
|
|
86
|
+
ValueError: If [`elevation`][(c).] is negative.
|
|
87
|
+
ValueError: If [`min_width`][(c).] is negative.
|
|
88
|
+
ValueError: If [`min_extended_width`][(c).] is negative.
|
|
84
89
|
"""
|
|
85
90
|
|
|
86
91
|
destinations: list[NavigationRailDestination] = field(default_factory=list)
|
|
@@ -130,14 +135,12 @@ class NavigationRail(LayoutControl):
|
|
|
130
135
|
|
|
131
136
|
bgcolor: Optional[ColorValue] = None
|
|
132
137
|
"""
|
|
133
|
-
Sets the color of the Container that holds
|
|
134
|
-
all of the NavigationRail's contents.
|
|
138
|
+
Sets the color of the Container that holds all of the NavigationRail's contents.
|
|
135
139
|
"""
|
|
136
140
|
|
|
137
141
|
indicator_color: Optional[ColorValue] = None
|
|
138
142
|
"""
|
|
139
|
-
The color of the navigation rail's
|
|
140
|
-
indicator.
|
|
143
|
+
The color of the navigation rail's indicator.
|
|
141
144
|
"""
|
|
142
145
|
|
|
143
146
|
indicator_shape: Optional[OutlinedBorder] = None
|
|
@@ -241,9 +244,9 @@ class NavigationRail(LayoutControl):
|
|
|
241
244
|
|
|
242
245
|
def before_update(self):
|
|
243
246
|
super().before_update()
|
|
244
|
-
if self.elevation is not None:
|
|
245
|
-
|
|
246
|
-
if self.min_width is not None:
|
|
247
|
-
|
|
248
|
-
if self.min_extended_width is not None:
|
|
249
|
-
|
|
247
|
+
if self.elevation is not None and self.elevation < 0:
|
|
248
|
+
raise ValueError("elevation cannot be negative")
|
|
249
|
+
if self.min_width is not None and self.min_width < 0:
|
|
250
|
+
raise ValueError("min_width cannot be negative")
|
|
251
|
+
if self.min_extended_width is not None and self.min_extended_width < 0:
|
|
252
|
+
raise ValueError("min_extended_width cannot be negative")
|
|
@@ -21,8 +21,11 @@ __all__ = ["OutlinedButton"]
|
|
|
21
21
|
class OutlinedButton(LayoutControl, AdaptiveControl):
|
|
22
22
|
"""
|
|
23
23
|
Outlined buttons are medium-emphasis buttons. They contain actions that are
|
|
24
|
-
important, but aren
|
|
24
|
+
important, but aren't the primary action in an app. Outlined buttons pair well with
|
|
25
25
|
filled buttons to indicate an alternative, secondary action.
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
ValueError: If neither [`icon`][(c).] nor [`content`][(c).] is provided.
|
|
26
29
|
"""
|
|
27
30
|
|
|
28
31
|
content: Optional[StrOrControl] = None
|
|
@@ -95,11 +98,12 @@ class OutlinedButton(LayoutControl, AdaptiveControl):
|
|
|
95
98
|
|
|
96
99
|
def before_update(self):
|
|
97
100
|
super().before_update()
|
|
98
|
-
|
|
101
|
+
if not (
|
|
99
102
|
self.icon
|
|
100
103
|
or isinstance(self.content, str)
|
|
101
104
|
or (isinstance(self.content, Control) and self.content.visible)
|
|
102
|
-
)
|
|
105
|
+
):
|
|
106
|
+
raise ValueError("at minimum, icon or a visible content must be provided")
|
|
103
107
|
|
|
104
108
|
async def focus(self):
|
|
105
109
|
await self._invoke_method("focus")
|
|
@@ -14,6 +14,11 @@ class ProgressBar(LayoutControl):
|
|
|
14
14
|
A material design linear progress indicator, also known as a progress bar.
|
|
15
15
|
|
|
16
16
|
A control that shows progress along a line.
|
|
17
|
+
|
|
18
|
+
Raises:
|
|
19
|
+
ValueError: If [`value`][(c).] is negative.
|
|
20
|
+
ValueError: If [`bar_height`][(c).] is negative.
|
|
21
|
+
ValueError: If [`semantics_value`][(c).] is negative.
|
|
17
22
|
"""
|
|
18
23
|
|
|
19
24
|
value: Optional[Number] = None
|
|
@@ -114,13 +119,16 @@ class ProgressBar(LayoutControl):
|
|
|
114
119
|
|
|
115
120
|
def before_update(self):
|
|
116
121
|
super().before_update()
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
122
|
+
if self.value is not None and self.value < 0:
|
|
123
|
+
raise ValueError(
|
|
124
|
+
f"value must be greater than or equal to 0, got {self.value}"
|
|
125
|
+
)
|
|
126
|
+
if self.bar_height is not None and self.bar_height < 0:
|
|
127
|
+
raise ValueError(
|
|
128
|
+
f"bar_height must be greater than or equal to 0, got {self.bar_height}"
|
|
129
|
+
)
|
|
130
|
+
if self.semantics_value is not None and self.semantics_value < 0:
|
|
131
|
+
raise ValueError(
|
|
132
|
+
f"semantics_value must be greater than or equal to 0, "
|
|
133
|
+
f"got {self.semantics_value}"
|
|
134
|
+
)
|
|
@@ -11,6 +11,9 @@ __all__ = ["RadioGroup"]
|
|
|
11
11
|
class RadioGroup(Control):
|
|
12
12
|
"""
|
|
13
13
|
Radio buttons let people select a single option from two or more choices.
|
|
14
|
+
|
|
15
|
+
Raises:
|
|
16
|
+
ValueError: If [`content`][(c).] is not visible.
|
|
14
17
|
"""
|
|
15
18
|
|
|
16
19
|
content: Control
|
|
@@ -33,4 +36,5 @@ class RadioGroup(Control):
|
|
|
33
36
|
|
|
34
37
|
def before_update(self):
|
|
35
38
|
super().before_update()
|
|
36
|
-
|
|
39
|
+
if not self.content.visible:
|
|
40
|
+
raise ValueError("content must be visible")
|
|
@@ -20,6 +20,11 @@ class RangeSlider(LayoutControl):
|
|
|
20
20
|
A range slider can be used to select from either a continuous or a discrete
|
|
21
21
|
set of values.
|
|
22
22
|
The default is to use a continuous range of values from min to max.
|
|
23
|
+
|
|
24
|
+
Raises:
|
|
25
|
+
ValueError: If [`end_value`][(c).] is greater than [`max`][(c).].
|
|
26
|
+
ValueError: If [`start_value`][(c).] is less than [`min`][(c).].
|
|
27
|
+
ValueError: If [`start_value`][(c).] is greater than [`end_value`][(c).].
|
|
23
28
|
"""
|
|
24
29
|
|
|
25
30
|
start_value: Number
|
|
@@ -124,17 +129,12 @@ class RangeSlider(LayoutControl):
|
|
|
124
129
|
"""
|
|
125
130
|
|
|
126
131
|
def before_update(self):
|
|
127
|
-
if self.max is not None:
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
)
|
|
136
|
-
|
|
137
|
-
assert self.start_value <= self.end_value, (
|
|
138
|
-
"start_value must be less than or equal to end_value"
|
|
139
|
-
)
|
|
132
|
+
if self.max is not None and self.end_value > self.max:
|
|
133
|
+
raise ValueError("end_value must be less than or equal to max")
|
|
134
|
+
|
|
135
|
+
if self.min is not None and self.start_value < self.min:
|
|
136
|
+
raise ValueError("start_value must be greater than or equal to min")
|
|
137
|
+
|
|
138
|
+
if self.start_value > self.end_value:
|
|
139
|
+
raise ValueError("start_value must be less than or equal to end_value")
|
|
140
140
|
pass
|
|
@@ -23,7 +23,7 @@ class Segment(Control):
|
|
|
23
23
|
A segment for a [`SegmentedButton`][flet.].
|
|
24
24
|
|
|
25
25
|
Raises:
|
|
26
|
-
|
|
26
|
+
ValueError: If neither [`icon`][(c).] nor [`label`][(c).] is set.
|
|
27
27
|
"""
|
|
28
28
|
|
|
29
29
|
value: str
|
|
@@ -45,12 +45,13 @@ class Segment(Control):
|
|
|
45
45
|
|
|
46
46
|
def before_update(self):
|
|
47
47
|
super().before_update()
|
|
48
|
-
|
|
48
|
+
if not (
|
|
49
49
|
(isinstance(self.icon, IconData))
|
|
50
50
|
or (isinstance(self.icon, Control) and self.icon.visible)
|
|
51
51
|
or (isinstance(self.label, str))
|
|
52
52
|
or (isinstance(self.label, Control) and self.label.visible)
|
|
53
|
-
)
|
|
53
|
+
):
|
|
54
|
+
raise ValueError("one of icon or label must be set and visible")
|
|
54
55
|
|
|
55
56
|
|
|
56
57
|
@control("SegmentedButton")
|
|
@@ -59,11 +60,13 @@ class SegmentedButton(LayoutControl):
|
|
|
59
60
|
A segmented button control.
|
|
60
61
|
|
|
61
62
|
Raises:
|
|
62
|
-
|
|
63
|
+
ValueError: If [`segments`][(c).] is empty or does not have at
|
|
63
64
|
least one visible `Segment`.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
ValueError: If [`selected`][(c).] is empty and
|
|
66
|
+
[`allow_empty_selection`][(c).] is `False`.
|
|
67
|
+
ValueError: If [`selected`][(c).] has more than one item and
|
|
68
|
+
[`allow_multiple_selection`][(c).] is `False`.
|
|
69
|
+
"""
|
|
67
70
|
|
|
68
71
|
segments: list[Segment]
|
|
69
72
|
"""
|
|
@@ -153,13 +156,14 @@ class SegmentedButton(LayoutControl):
|
|
|
153
156
|
|
|
154
157
|
def before_update(self):
|
|
155
158
|
super().before_update()
|
|
156
|
-
|
|
157
|
-
"segments must have at minimum one visible Segment"
|
|
158
|
-
)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
159
|
+
if not any(segment.visible for segment in self.segments):
|
|
160
|
+
raise ValueError("segments must have at minimum one visible Segment")
|
|
161
|
+
if len(self.selected) == 0 and not self.allow_empty_selection:
|
|
162
|
+
raise ValueError(
|
|
163
|
+
"allow_empty_selection must be True for selected to be empty"
|
|
164
|
+
)
|
|
165
|
+
if len(self.selected) >= 2 and not self.allow_multiple_selection:
|
|
166
|
+
raise ValueError(
|
|
167
|
+
"allow_multiple_selection must be True for selected to "
|
|
168
|
+
"have more than one item"
|
|
169
|
+
)
|
|
@@ -14,7 +14,7 @@ class SelectionArea(Control):
|
|
|
14
14
|
selection for its child control.
|
|
15
15
|
|
|
16
16
|
Raises:
|
|
17
|
-
|
|
17
|
+
ValueError: If [`content`][(c).] is not visible
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
content: Control
|
|
@@ -33,4 +33,5 @@ class SelectionArea(Control):
|
|
|
33
33
|
|
|
34
34
|
def before_update(self):
|
|
35
35
|
super().before_update()
|
|
36
|
-
|
|
36
|
+
if not self.content.visible:
|
|
37
|
+
raise ValueError("content must be visible")
|
flet/controls/material/slider.py
CHANGED
|
@@ -34,9 +34,9 @@ class Slider(LayoutControl, AdaptiveControl):
|
|
|
34
34
|
of setting changes.
|
|
35
35
|
|
|
36
36
|
Raises:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
ValueError: If [`min`][(c).] is greater than [`max`][(c).].
|
|
38
|
+
ValueError: If [`value`][(c).] is less than [`min`][(c).].
|
|
39
|
+
ValueError: If [`value`][(c).] is greater than [`max`][(c).].
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
42
|
value: Optional[Number] = None
|
|
@@ -216,12 +216,16 @@ class Slider(LayoutControl, AdaptiveControl):
|
|
|
216
216
|
|
|
217
217
|
def before_update(self):
|
|
218
218
|
super().before_update()
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
219
|
+
if self.max is not None and self.min > self.max:
|
|
220
|
+
raise ValueError(
|
|
221
|
+
f"min ({self.min}) must be less than or equal to max ({self.max})"
|
|
222
|
+
)
|
|
223
|
+
if self.value is not None and self.value < self.min:
|
|
224
|
+
raise ValueError(
|
|
225
|
+
f"value ({self.value}) must be greater than or "
|
|
226
|
+
f"equal to min ({self.min})"
|
|
227
|
+
)
|
|
228
|
+
if self.value is not None and self.value > self.max:
|
|
229
|
+
raise ValueError(
|
|
230
|
+
f"value ({self.value}) must be less than or equal to max ({self.max})"
|
|
231
|
+
)
|
|
@@ -93,6 +93,11 @@ class SnackBar(DialogControl):
|
|
|
93
93
|
"""
|
|
94
94
|
A lightweight message with an optional action which briefly displays at the
|
|
95
95
|
bottom of the screen.
|
|
96
|
+
|
|
97
|
+
Raises:
|
|
98
|
+
ValueError: If [`content`][(c).] is not a string or visible control.
|
|
99
|
+
ValueError: If [`action_overflow_threshold`][(c).] is not between 0 and 1.
|
|
100
|
+
ValueError: If [`elevation`][(c).] is negative.
|
|
96
101
|
"""
|
|
97
102
|
|
|
98
103
|
content: StrOrControl
|
|
@@ -229,13 +234,16 @@ class SnackBar(DialogControl):
|
|
|
229
234
|
|
|
230
235
|
def before_update(self):
|
|
231
236
|
super().before_update()
|
|
232
|
-
|
|
233
|
-
isinstance(self.content,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
237
|
+
if not (
|
|
238
|
+
isinstance(self.content, str)
|
|
239
|
+
or (isinstance(self.content, Control) and self.content.visible)
|
|
240
|
+
):
|
|
241
|
+
raise ValueError("content must be a string or a visible control")
|
|
242
|
+
if self.action_overflow_threshold is not None and not (
|
|
243
|
+
0 <= self.action_overflow_threshold <= 1
|
|
244
|
+
):
|
|
245
|
+
raise ValueError(
|
|
246
|
+
"action_overflow_threshold must be between 0 and 1 inclusive"
|
|
247
|
+
)
|
|
248
|
+
if self.elevation is not None and self.elevation < 0:
|
|
249
|
+
raise ValueError("elevation cannot be negative")
|
flet/controls/material/switch.py
CHANGED
|
@@ -28,7 +28,7 @@ class Switch(LayoutControl, AdaptiveControl):
|
|
|
28
28
|
For example, "On/Off", "Show/Hide".
|
|
29
29
|
|
|
30
30
|
Raises:
|
|
31
|
-
|
|
31
|
+
ValueError: If [`splash_radius`][(c).] is negative.
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
34
|
label: Optional[StrOrControl] = None
|
|
@@ -225,7 +225,8 @@ class Switch(LayoutControl, AdaptiveControl):
|
|
|
225
225
|
|
|
226
226
|
def before_update(self):
|
|
227
227
|
super().before_update()
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
228
|
+
if self.splash_radius is not None and self.splash_radius < 0:
|
|
229
|
+
raise ValueError(
|
|
230
|
+
"splash_radius must be greater than or equal to 0, "
|
|
231
|
+
f"got {self.splash_radius}"
|
|
232
|
+
)
|
flet/controls/material/tabs.py
CHANGED
|
@@ -316,9 +316,9 @@ class TabBar(LayoutControl, AdaptiveControl):
|
|
|
316
316
|
on text headers to articulate the different sections of content.
|
|
317
317
|
|
|
318
318
|
Raises:
|
|
319
|
-
|
|
319
|
+
ValueError: If [`indicator`][(c).] is None and
|
|
320
320
|
[`indicator_thickness`][(c).] is not strictly greater than 0.
|
|
321
|
-
|
|
321
|
+
ValueError: If [`tab_alignment`][(c).] is not valid for
|
|
322
322
|
the given [`scrollable`][(c).] state.
|
|
323
323
|
"""
|
|
324
324
|
|
|
@@ -538,20 +538,25 @@ class TabBar(LayoutControl, AdaptiveControl):
|
|
|
538
538
|
|
|
539
539
|
def before_update(self):
|
|
540
540
|
super().before_update()
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
541
|
+
if self.indicator is None and self.indicator_thickness <= 0.0:
|
|
542
|
+
raise ValueError(
|
|
543
|
+
f"indicator_thickness must be strictly greater than zero if indicator "
|
|
544
|
+
f"is None, got {self.indicator_thickness}"
|
|
545
|
+
)
|
|
545
546
|
valid_alignments = (
|
|
546
547
|
[TabAlignment.CENTER, TabAlignment.FILL]
|
|
547
548
|
if not self.scrollable
|
|
548
549
|
else [TabAlignment.START, TabAlignment.START_OFFSET, TabAlignment.CENTER]
|
|
549
550
|
)
|
|
550
551
|
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
)
|
|
552
|
+
if (
|
|
553
|
+
self.tab_alignment is not None
|
|
554
|
+
and self.tab_alignment not in valid_alignments
|
|
555
|
+
):
|
|
556
|
+
raise ValueError(
|
|
557
|
+
f"If scrollable is {self.scrollable}, tab_alignment must be one of: "
|
|
558
|
+
f"{', '.join(f'TabAlignment.{a.name}' for a in valid_alignments)}."
|
|
559
|
+
)
|
|
555
560
|
|
|
556
561
|
|
|
557
562
|
@control("Tab")
|
|
@@ -560,7 +565,7 @@ class Tab(AdaptiveControl):
|
|
|
560
565
|
A Material Design [`TabBar`][flet.] tab.
|
|
561
566
|
|
|
562
567
|
Raises:
|
|
563
|
-
|
|
568
|
+
ValueError: If both [`label`][(c).] and [`icon`][(c).] are not set.
|
|
564
569
|
"""
|
|
565
570
|
|
|
566
571
|
label: Optional[StrOrControl] = None
|
|
@@ -599,6 +604,5 @@ class Tab(AdaptiveControl):
|
|
|
599
604
|
|
|
600
605
|
def before_update(self):
|
|
601
606
|
super().before_update()
|
|
602
|
-
|
|
603
|
-
"Tab must have at least label or icon property set"
|
|
604
|
-
)
|
|
607
|
+
if not ((self.label is not None) or (self.icon is not None)):
|
|
608
|
+
raise ValueError("Tab must have at least label or icon property set")
|