flet 0.70.0.dev6365__py3-none-any.whl → 0.70.0.dev6412__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 +2 -0
- flet/components/hooks/use_state.py +38 -15
- flet/controls/base_control.py +13 -10
- flet/controls/base_page.py +10 -2
- flet/controls/border.py +1 -1
- flet/controls/box.py +18 -16
- flet/controls/colors.py +5 -4
- flet/controls/context.py +1 -1
- flet/controls/control_event.py +2 -1
- flet/controls/core/dismissible.py +1 -5
- flet/controls/core/interactive_viewer.py +10 -23
- flet/controls/core/responsive_row.py +1 -2
- flet/controls/core/row.py +1 -2
- flet/controls/core/stack.py +27 -0
- flet/controls/core/view.py +2 -4
- flet/controls/core/window.py +12 -8
- flet/controls/cupertino/cupertino_colors.py +8 -6
- flet/controls/material/app_bar.py +5 -6
- flet/controls/material/auto_complete.py +41 -6
- flet/controls/material/chip.py +4 -11
- flet/controls/material/circle_avatar.py +5 -6
- flet/controls/material/dropdown.py +11 -5
- flet/controls/material/dropdownm2.py +4 -5
- flet/controls/material/expansion_panel.py +19 -15
- flet/controls/material/menu_bar.py +7 -5
- flet/controls/material/menu_item_button.py +1 -1
- flet/controls/material/snack_bar.py +1 -4
- flet/controls/material/submenu_button.py +19 -0
- flet/controls/material/switch.py +5 -0
- flet/controls/material/tabs.py +7 -12
- flet/controls/material/text_button.py +8 -0
- flet/controls/material/time_picker.py +8 -0
- flet/controls/page.py +48 -1
- flet/controls/services/shared_preferences.py +2 -1
- flet/controls/types.py +29 -3
- flet/pubsub/pubsub_hub.py +2 -1
- flet/testing/flet_test_app.py +11 -6
- flet/utils/pip.py +19 -14
- flet/version.py +1 -1
- {flet-0.70.0.dev6365.dist-info → flet-0.70.0.dev6412.dist-info}/METADATA +1 -1
- {flet-0.70.0.dev6365.dist-info → flet-0.70.0.dev6412.dist-info}/RECORD +44 -44
- {flet-0.70.0.dev6365.dist-info → flet-0.70.0.dev6412.dist-info}/WHEEL +0 -0
- {flet-0.70.0.dev6365.dist-info → flet-0.70.0.dev6412.dist-info}/entry_points.txt +0 -0
- {flet-0.70.0.dev6365.dist-info → flet-0.70.0.dev6412.dist-info}/top_level.txt +0 -0
flet/__init__.py
CHANGED
|
@@ -491,6 +491,7 @@ from flet.controls.types import (
|
|
|
491
491
|
ClipBehavior,
|
|
492
492
|
ColorValue,
|
|
493
493
|
CrossAxisAlignment,
|
|
494
|
+
DeviceOrientation,
|
|
494
495
|
FloatingActionButtonLocation,
|
|
495
496
|
FontWeight,
|
|
496
497
|
IconDataOrControl,
|
|
@@ -658,6 +659,7 @@ __all__ = [
|
|
|
658
659
|
"DateTimeValue",
|
|
659
660
|
"DecorationImage",
|
|
660
661
|
"DeviceInfo",
|
|
662
|
+
"DeviceOrientation",
|
|
661
663
|
"DialogControl",
|
|
662
664
|
"DialogTheme",
|
|
663
665
|
"DismissDirection",
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from collections.abc import Callable
|
|
2
4
|
from dataclasses import dataclass
|
|
3
5
|
from typing import Any, TypeVar
|
|
@@ -6,6 +8,9 @@ from flet.components.hooks.hook import Hook
|
|
|
6
8
|
from flet.components.observable import Observable, ObservableSubscription
|
|
7
9
|
from flet.components.utils import current_component
|
|
8
10
|
|
|
11
|
+
StateT = TypeVar("StateT")
|
|
12
|
+
Updater = Callable[[StateT], StateT]
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
@dataclass
|
|
11
16
|
class StateHook(Hook):
|
|
@@ -14,20 +19,21 @@ class StateHook(Hook):
|
|
|
14
19
|
version: int = 0
|
|
15
20
|
|
|
16
21
|
|
|
17
|
-
StateT = TypeVar("StateT")
|
|
18
|
-
|
|
19
|
-
|
|
20
22
|
def use_state(
|
|
21
23
|
initial: StateT | Callable[[], StateT],
|
|
22
|
-
) -> tuple[StateT, Callable[[StateT], None]]:
|
|
24
|
+
) -> tuple[StateT, Callable[[StateT | Updater], None]]:
|
|
23
25
|
"""
|
|
24
|
-
|
|
26
|
+
Adds state to a function component, similar to React's useState().
|
|
27
|
+
|
|
28
|
+
The returned setter accepts either:
|
|
29
|
+
- a new value, or
|
|
30
|
+
- a function receiving the previous state and returning the next one.
|
|
25
31
|
|
|
26
32
|
Args:
|
|
27
|
-
initial: Initial state value or a function
|
|
33
|
+
initial: Initial state value or a function returning it.
|
|
28
34
|
|
|
29
35
|
Returns:
|
|
30
|
-
|
|
36
|
+
(value, set_value) tuple.
|
|
31
37
|
"""
|
|
32
38
|
component = current_component()
|
|
33
39
|
hook = component.use_hook(
|
|
@@ -37,17 +43,34 @@ def use_state(
|
|
|
37
43
|
)
|
|
38
44
|
)
|
|
39
45
|
|
|
40
|
-
def update_subscription(
|
|
41
|
-
if
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
def update_subscription(h: StateHook):
|
|
47
|
+
# Detach previous subscription if any
|
|
48
|
+
if h.subscription:
|
|
49
|
+
component._detach_observable_subscription(h.subscription)
|
|
50
|
+
h.subscription = None
|
|
51
|
+
|
|
52
|
+
# Attach new subscription if value is Observable
|
|
53
|
+
if isinstance(h.value, Observable):
|
|
54
|
+
h.subscription = component._attach_observable_subscription(h.value)
|
|
46
55
|
|
|
47
56
|
update_subscription(hook)
|
|
48
57
|
|
|
49
|
-
def set_state(
|
|
50
|
-
|
|
58
|
+
def set_state(new_value_or_fn: StateT | Updater):
|
|
59
|
+
"""
|
|
60
|
+
Update the state value.
|
|
61
|
+
|
|
62
|
+
Can be called with either:
|
|
63
|
+
- a direct new value, or
|
|
64
|
+
- a function that takes the current value and returns the next one.
|
|
65
|
+
"""
|
|
66
|
+
# Compute next value
|
|
67
|
+
new_value = (
|
|
68
|
+
new_value_or_fn(hook.value)
|
|
69
|
+
if callable(new_value_or_fn)
|
|
70
|
+
else new_value_or_fn
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Only trigger update if value changed (shallow equality)
|
|
51
74
|
if new_value != hook.value:
|
|
52
75
|
hook.value = new_value
|
|
53
76
|
update_subscription(hook)
|
flet/controls/base_control.py
CHANGED
|
@@ -233,9 +233,10 @@ class BaseControl:
|
|
|
233
233
|
def update(self) -> None:
|
|
234
234
|
if hasattr(self, "_frozen"):
|
|
235
235
|
raise Exception("Frozen control cannot be updated.")
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
if not self.page:
|
|
237
|
+
raise RuntimeError(
|
|
238
|
+
f"{self.__class__.__qualname__} Control must be added to the page first"
|
|
239
|
+
)
|
|
239
240
|
self.page.update(self)
|
|
240
241
|
|
|
241
242
|
async def _invoke_method(
|
|
@@ -244,9 +245,10 @@ class BaseControl:
|
|
|
244
245
|
arguments: Optional[dict[str, Any]] = None,
|
|
245
246
|
timeout: Optional[float] = None,
|
|
246
247
|
) -> Any:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
if not self.page:
|
|
249
|
+
raise RuntimeError(
|
|
250
|
+
f"{self.__class__.__qualname__} Control must be added to the page first"
|
|
251
|
+
)
|
|
250
252
|
|
|
251
253
|
return await self.page.session.invoke_method(
|
|
252
254
|
self._i, method_name, arguments, timeout
|
|
@@ -282,10 +284,11 @@ class BaseControl:
|
|
|
282
284
|
|
|
283
285
|
controls_log.debug(f"Trigger event {self}.{field_name} {e}")
|
|
284
286
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
if not self.page:
|
|
288
|
+
raise RuntimeError(
|
|
289
|
+
"Control must be added to a page before triggering events. Use "
|
|
290
|
+
"page.add(control) or add it to a parent control that's on a page."
|
|
291
|
+
)
|
|
289
292
|
session = self.page.session
|
|
290
293
|
|
|
291
294
|
# Handle async and sync event handlers accordingly
|
flet/controls/base_page.py
CHANGED
|
@@ -35,6 +35,7 @@ from flet.controls.types import (
|
|
|
35
35
|
LocaleConfiguration,
|
|
36
36
|
MainAxisAlignment,
|
|
37
37
|
Number,
|
|
38
|
+
Orientation,
|
|
38
39
|
ScrollMode,
|
|
39
40
|
ThemeMode,
|
|
40
41
|
)
|
|
@@ -75,6 +76,11 @@ class PageMediaData:
|
|
|
75
76
|
The number of device pixels for each logical pixel.
|
|
76
77
|
"""
|
|
77
78
|
|
|
79
|
+
orientation: Orientation
|
|
80
|
+
"""
|
|
81
|
+
The orientation of the page.
|
|
82
|
+
"""
|
|
83
|
+
|
|
78
84
|
|
|
79
85
|
@dataclass
|
|
80
86
|
class PageResizeEvent(Event["BasePage"]):
|
|
@@ -184,7 +190,7 @@ class BasePage(AdaptiveControl):
|
|
|
184
190
|
|
|
185
191
|
on_media_change: Optional[EventHandler[PageMediaData]] = None
|
|
186
192
|
"""
|
|
187
|
-
Called when `media` has changed.
|
|
193
|
+
Called when [`media`][(c).] has changed.
|
|
188
194
|
"""
|
|
189
195
|
|
|
190
196
|
media: PageMediaData = field(
|
|
@@ -193,6 +199,7 @@ class BasePage(AdaptiveControl):
|
|
|
193
199
|
view_padding=Padding.zero(),
|
|
194
200
|
view_insets=Padding.zero(),
|
|
195
201
|
device_pixel_ratio=0,
|
|
202
|
+
orientation=Orientation.PORTRAIT,
|
|
196
203
|
)
|
|
197
204
|
)
|
|
198
205
|
"""
|
|
@@ -231,7 +238,8 @@ class BasePage(AdaptiveControl):
|
|
|
231
238
|
_dialogs: "Dialogs" = field(default_factory=lambda: Dialogs())
|
|
232
239
|
|
|
233
240
|
def __default_view(self) -> View:
|
|
234
|
-
|
|
241
|
+
if len(self.views) == 0:
|
|
242
|
+
raise RuntimeError("views list is empty.")
|
|
235
243
|
return self.views[0]
|
|
236
244
|
|
|
237
245
|
def update(self, *controls) -> None:
|
flet/controls/border.py
CHANGED
flet/controls/box.py
CHANGED
|
@@ -336,17 +336,17 @@ class BoxDecoration:
|
|
|
336
336
|
"""
|
|
337
337
|
|
|
338
338
|
def __post_init__(self):
|
|
339
|
-
|
|
339
|
+
if not (
|
|
340
340
|
self.blend_mode is None
|
|
341
341
|
or self.bgcolor is not None
|
|
342
342
|
or self.gradient is not None
|
|
343
|
-
)
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
343
|
+
):
|
|
344
|
+
raise ValueError(
|
|
345
|
+
"blend_mode applies to the BoxDecoration's background color "
|
|
346
|
+
"or gradient, but no color or gradient was provided"
|
|
347
|
+
)
|
|
348
|
+
if self.shape == BoxShape.CIRCLE and self.border_radius:
|
|
349
|
+
raise ValueError("border_radius must be None when shape is BoxShape.CIRCLE")
|
|
350
350
|
|
|
351
351
|
def copy(
|
|
352
352
|
self,
|
|
@@ -414,14 +414,16 @@ class BoxConstraints:
|
|
|
414
414
|
"""
|
|
415
415
|
|
|
416
416
|
def __post_init__(self):
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
417
|
+
if not (0 <= self.min_width <= self.max_width <= float("inf")):
|
|
418
|
+
raise ValueError(
|
|
419
|
+
"min_width and max_width must be between 0 and infinity "
|
|
420
|
+
"and min_width must be less than or equal to max_width"
|
|
421
|
+
)
|
|
422
|
+
if not (0 <= self.min_height <= self.max_height <= float("inf")):
|
|
423
|
+
raise ValueError(
|
|
424
|
+
"min_height and max_height must be between 0 and infinity "
|
|
425
|
+
"and min_height must be less than or equal to max_height"
|
|
426
|
+
)
|
|
425
427
|
|
|
426
428
|
def copy(
|
|
427
429
|
self,
|
flet/controls/colors.py
CHANGED
|
@@ -120,11 +120,12 @@ class Colors(str, Enum):
|
|
|
120
120
|
'red,0.5'
|
|
121
121
|
|
|
122
122
|
Raises:
|
|
123
|
-
|
|
123
|
+
ValueError: If the opacity is not between `0` and `1` (inclusive).
|
|
124
124
|
"""
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
if not (0 <= opacity <= 1):
|
|
126
|
+
raise ValueError(
|
|
127
|
+
f"opacity must be between 0.0 and 1.0 inclusive, got {opacity}"
|
|
128
|
+
)
|
|
128
129
|
color_str = color.value if isinstance(color, Enum) else color
|
|
129
130
|
return f"{color_str},{opacity}"
|
|
130
131
|
|
flet/controls/context.py
CHANGED
flet/controls/control_event.py
CHANGED
|
@@ -97,7 +97,8 @@ class Event(Generic[EventControlType]):
|
|
|
97
97
|
|
|
98
98
|
@property
|
|
99
99
|
def page(self) -> Union["Page", "BasePage"]:
|
|
100
|
-
|
|
100
|
+
if not self.control.page:
|
|
101
|
+
raise RuntimeError("event control is not attached to a page")
|
|
101
102
|
return self.control.page
|
|
102
103
|
|
|
103
104
|
@property
|
|
@@ -70,12 +70,8 @@ class Dismissible(LayoutControl, AdaptiveControl):
|
|
|
70
70
|
A control that is stacked behind the [`content`][(c).] and is
|
|
71
71
|
exposed when it has been dragged up or to the left.
|
|
72
72
|
|
|
73
|
-
Note:
|
|
74
|
-
Can only be specified if [`background`][(c).] is also
|
|
75
|
-
specified/visible.
|
|
76
|
-
|
|
77
73
|
Raises:
|
|
78
|
-
ValueError: If
|
|
74
|
+
ValueError: If it is provided and visible
|
|
79
75
|
but the [`background`][(c).] is not provided and visible.
|
|
80
76
|
"""
|
|
81
77
|
|
|
@@ -58,36 +58,25 @@ class InteractiveViewer(LayoutControl):
|
|
|
58
58
|
"""
|
|
59
59
|
The maximum allowed scale.
|
|
60
60
|
|
|
61
|
-
Note:
|
|
62
|
-
Must be greater than or equal to [`min_scale`][(c).].
|
|
63
|
-
|
|
64
61
|
Raises:
|
|
65
|
-
ValueError: If
|
|
62
|
+
ValueError: If it is not greater than `0` or is less than
|
|
66
63
|
[`min_scale`][(c).].
|
|
67
|
-
"""
|
|
64
|
+
"""
|
|
68
65
|
|
|
69
66
|
min_scale: Number = 0.8
|
|
70
67
|
"""
|
|
71
68
|
The minimum allowed scale.
|
|
72
69
|
|
|
73
|
-
Note:
|
|
74
|
-
Must be greater than `0` and less than or equal
|
|
75
|
-
to [`max_scale`][(c).].
|
|
76
|
-
|
|
77
70
|
Raises:
|
|
78
|
-
ValueError: If
|
|
71
|
+
ValueError: If it is not greater than `0` or less than [`max_scale`][(c).].
|
|
79
72
|
"""
|
|
80
73
|
|
|
81
74
|
interaction_end_friction_coefficient: Number = 0.0000135
|
|
82
75
|
"""
|
|
83
76
|
Changes the deceleration behavior after a gesture.
|
|
84
77
|
|
|
85
|
-
Note:
|
|
86
|
-
Must be greater than `0`.
|
|
87
|
-
|
|
88
78
|
Raises:
|
|
89
|
-
ValueError: If
|
|
90
|
-
than `0`.
|
|
79
|
+
ValueError: If it is less than or equal to `0`.
|
|
91
80
|
"""
|
|
92
81
|
|
|
93
82
|
scale_factor: Number = 200
|
|
@@ -97,22 +86,23 @@ class InteractiveViewer(LayoutControl):
|
|
|
97
86
|
|
|
98
87
|
clip_behavior: ClipBehavior = ClipBehavior.HARD_EDGE
|
|
99
88
|
"""
|
|
100
|
-
|
|
89
|
+
Defines how to clip the [`content`][(c).].
|
|
101
90
|
"""
|
|
102
91
|
|
|
103
92
|
alignment: Optional[Alignment] = None
|
|
104
93
|
"""
|
|
105
|
-
|
|
94
|
+
The alignment of the [`content`][(c).] within this viewer.
|
|
106
95
|
"""
|
|
107
96
|
|
|
108
97
|
boundary_margin: MarginValue = 0
|
|
109
98
|
"""
|
|
110
|
-
A margin for the visible boundaries of the `content
|
|
99
|
+
A margin for the visible boundaries of the [`content`][(c).].
|
|
111
100
|
"""
|
|
112
101
|
|
|
113
102
|
interaction_update_interval: int = 200
|
|
114
103
|
"""
|
|
115
|
-
The interval (in milliseconds) at which the
|
|
104
|
+
The interval (in milliseconds) at which the
|
|
105
|
+
[`on_interaction_update`][(c).] event is fired.
|
|
116
106
|
"""
|
|
117
107
|
|
|
118
108
|
on_interaction_start: Optional[
|
|
@@ -149,10 +139,7 @@ class InteractiveViewer(LayoutControl):
|
|
|
149
139
|
"max_scale must be greater than or equal to min_scale, "
|
|
150
140
|
f"got max_scale={self.max_scale}, min_scale={self.min_scale}"
|
|
151
141
|
)
|
|
152
|
-
if
|
|
153
|
-
self.interaction_end_friction_coefficient is not None
|
|
154
|
-
and self.interaction_end_friction_coefficient <= 0
|
|
155
|
-
):
|
|
142
|
+
if self.interaction_end_friction_coefficient <= 0:
|
|
156
143
|
raise ValueError(
|
|
157
144
|
"interaction_end_friction_coefficient must be greater than 0, "
|
|
158
145
|
f"got {self.interaction_end_friction_coefficient}"
|
|
@@ -56,8 +56,7 @@ class ResponsiveRow(LayoutControl, AdaptiveControl):
|
|
|
56
56
|
|
|
57
57
|
Note:
|
|
58
58
|
Has effect only when [`alignment`][(c).] is set to
|
|
59
|
-
[`MainAxisAlignment.START`][flet.],
|
|
60
|
-
[`MainAxisAlignment.END`][flet.],
|
|
59
|
+
[`MainAxisAlignment.START`][flet.], [`MainAxisAlignment.END`][flet.],
|
|
61
60
|
or [`MainAxisAlignment.CENTER`][flet.].
|
|
62
61
|
"""
|
|
63
62
|
|
flet/controls/core/row.py
CHANGED
|
@@ -40,8 +40,7 @@ class Row(LayoutControl, ScrollableControl, AdaptiveControl):
|
|
|
40
40
|
|
|
41
41
|
Note:
|
|
42
42
|
Has effect only when [`alignment`][(c).] is set to
|
|
43
|
-
[`MainAxisAlignment.START`][flet.],
|
|
44
|
-
[`MainAxisAlignment.END`][flet.],
|
|
43
|
+
[`MainAxisAlignment.START`][flet.], [`MainAxisAlignment.END`][flet.],
|
|
45
44
|
or [`MainAxisAlignment.CENTER`][flet.].
|
|
46
45
|
"""
|
|
47
46
|
|
flet/controls/core/stack.py
CHANGED
|
@@ -31,6 +31,33 @@ class Stack(LayoutControl, AdaptiveControl):
|
|
|
31
31
|
Stack is also useful if you want to implement implicit animations
|
|
32
32
|
(https://flet.dev/docs/guides/python/animations/) that require knowing absolute
|
|
33
33
|
position of a target value.
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
ft.Stack(
|
|
37
|
+
width=300,
|
|
38
|
+
height=300,
|
|
39
|
+
controls=[
|
|
40
|
+
ft.Image(
|
|
41
|
+
src="https://picsum.photos/300/300",
|
|
42
|
+
width=300,
|
|
43
|
+
height=300,
|
|
44
|
+
fit=ft.BoxFit.CONTAIN,
|
|
45
|
+
),
|
|
46
|
+
ft.Row(
|
|
47
|
+
alignment=ft.MainAxisAlignment.CENTER,
|
|
48
|
+
controls=[
|
|
49
|
+
ft.Text(
|
|
50
|
+
value="Image title",
|
|
51
|
+
color=ft.Colors.SURFACE_TINT,
|
|
52
|
+
size=40,
|
|
53
|
+
weight=ft.FontWeight.BOLD,
|
|
54
|
+
opacity=0.5,
|
|
55
|
+
)
|
|
56
|
+
],
|
|
57
|
+
),
|
|
58
|
+
],
|
|
59
|
+
)
|
|
60
|
+
```
|
|
34
61
|
"""
|
|
35
62
|
|
|
36
63
|
controls: list[Control] = field(default_factory=list)
|
flet/controls/core/view.py
CHANGED
|
@@ -131,10 +131,8 @@ class View(ScrollableControl, LayoutControl):
|
|
|
131
131
|
|
|
132
132
|
Note:
|
|
133
133
|
Has effect only when [`vertical_alignment`][(c).]
|
|
134
|
-
is set to
|
|
135
|
-
[`MainAxisAlignment.
|
|
136
|
-
[`MainAxisAlignment.END`][flet.],
|
|
137
|
-
or [`MainAxisAlignment.CENTER`][flet.].
|
|
134
|
+
is set to [`MainAxisAlignment.START`][flet.],
|
|
135
|
+
[`MainAxisAlignment.END`][flet.], or [`MainAxisAlignment.CENTER`][flet.].
|
|
138
136
|
"""
|
|
139
137
|
|
|
140
138
|
padding: Optional[PaddingValue] = field(default_factory=lambda: Padding.all(10))
|
flet/controls/core/window.py
CHANGED
|
@@ -54,7 +54,7 @@ class Window(BaseControl):
|
|
|
54
54
|
"""
|
|
55
55
|
Controls the app window.
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
Limitation:
|
|
58
58
|
This control is for Desktop platforms (macOS, Windows, Linux) only.
|
|
59
59
|
"""
|
|
60
60
|
|
|
@@ -113,8 +113,8 @@ class Window(BaseControl):
|
|
|
113
113
|
"""
|
|
114
114
|
Defines the opacity of the app window.
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
Raises:
|
|
117
|
+
ValueError: If it is not between `0.0` and `1.0` inclusive.
|
|
118
118
|
"""
|
|
119
119
|
|
|
120
120
|
aspect_ratio: Optional[Number] = None
|
|
@@ -160,7 +160,7 @@ class Window(BaseControl):
|
|
|
160
160
|
"""
|
|
161
161
|
Whether the app window can be moved.
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
Limitation:
|
|
164
164
|
Has effect on macOS only.
|
|
165
165
|
"""
|
|
166
166
|
|
|
@@ -178,7 +178,7 @@ class Window(BaseControl):
|
|
|
178
178
|
"""
|
|
179
179
|
Whether the app window should always be displayed below other windows.
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
Limitation:
|
|
182
182
|
Has effect on Linux and Windows only.
|
|
183
183
|
"""
|
|
184
184
|
|
|
@@ -204,7 +204,7 @@ class Window(BaseControl):
|
|
|
204
204
|
"""
|
|
205
205
|
Whether to hide the app window's title bar buttons.
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
Limitation:
|
|
208
208
|
Has effect on macOS only.
|
|
209
209
|
"""
|
|
210
210
|
|
|
@@ -246,7 +246,7 @@ class Window(BaseControl):
|
|
|
246
246
|
"""
|
|
247
247
|
Sets a badge label on the app window.
|
|
248
248
|
|
|
249
|
-
|
|
249
|
+
Limitation:
|
|
250
250
|
Has effect on macOS only.
|
|
251
251
|
"""
|
|
252
252
|
|
|
@@ -256,7 +256,7 @@ class Window(BaseControl):
|
|
|
256
256
|
|
|
257
257
|
The file should have the `.ico` extension.
|
|
258
258
|
|
|
259
|
-
|
|
259
|
+
Limitation:
|
|
260
260
|
Has effect on Windows only.
|
|
261
261
|
"""
|
|
262
262
|
|
|
@@ -275,6 +275,10 @@ class Window(BaseControl):
|
|
|
275
275
|
def __post_init__(self, ref) -> None:
|
|
276
276
|
super().__post_init__(ref)
|
|
277
277
|
self._i = 2
|
|
278
|
+
if self.opacity < 0.0 or self.opacity > 1.0:
|
|
279
|
+
raise ValueError(
|
|
280
|
+
f"opacity must be between 0.0 and 1.0 inclusive, got {self.opacity}"
|
|
281
|
+
)
|
|
278
282
|
|
|
279
283
|
async def wait_until_ready_to_show(self):
|
|
280
284
|
"""
|
|
@@ -19,7 +19,7 @@ Code to sort the members:
|
|
|
19
19
|
```
|
|
20
20
|
s = sorted(CupertinoColors, key=lambda i: i.name)
|
|
21
21
|
for i in s:
|
|
22
|
-
print(f
|
|
22
|
+
print(f'{i.name} = "{i.value}"')
|
|
23
23
|
```
|
|
24
24
|
"""
|
|
25
25
|
|
|
@@ -54,18 +54,20 @@ class CupertinoColors(str, Enum):
|
|
|
54
54
|
color: The color to apply opacity to.
|
|
55
55
|
|
|
56
56
|
Returns:
|
|
57
|
-
A string representing the color with opacity,
|
|
57
|
+
A string representing the color with opacity,
|
|
58
|
+
in the format `"color,opacity"`.
|
|
58
59
|
|
|
59
60
|
Examples:
|
|
60
61
|
>>> CupertinoColors.with_opacity(0.5, CupertinoColors.WHITE)
|
|
61
62
|
'white,0.5'
|
|
62
63
|
|
|
63
64
|
Raises:
|
|
64
|
-
|
|
65
|
+
ValueError: If the opacity is not between `0` and `1` (inclusive).
|
|
65
66
|
"""
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if not (0 <= opacity <= 1):
|
|
68
|
+
raise ValueError(
|
|
69
|
+
f"opacity must be between 0.0 and 1.0 inclusive, got {opacity}"
|
|
70
|
+
)
|
|
69
71
|
color_str = color.value if isinstance(color, Enum) else color
|
|
70
72
|
return f"{color_str},{opacity}"
|
|
71
73
|
|
|
@@ -103,7 +103,7 @@ class AppBar(AdaptiveControl):
|
|
|
103
103
|
(when [`Theme.use_material3`][flet.] is `False`).
|
|
104
104
|
|
|
105
105
|
Raises:
|
|
106
|
-
ValueError: If
|
|
106
|
+
ValueError: If it is less than `0.0`.
|
|
107
107
|
"""
|
|
108
108
|
|
|
109
109
|
elevation_on_scroll: Optional[Number] = None
|
|
@@ -111,7 +111,7 @@ class AppBar(AdaptiveControl):
|
|
|
111
111
|
The elevation to be used if this app bar has something scrolled underneath it.
|
|
112
112
|
|
|
113
113
|
Raises:
|
|
114
|
-
ValueError: If
|
|
114
|
+
ValueError: If it is less than `0.0`.
|
|
115
115
|
"""
|
|
116
116
|
|
|
117
117
|
shadow_color: Optional[ColorValue] = None
|
|
@@ -183,12 +183,11 @@ class AppBar(AdaptiveControl):
|
|
|
183
183
|
"""
|
|
184
184
|
The opacity of the toolbar.
|
|
185
185
|
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
- `0.0`: transparent
|
|
187
|
+
- `1.0`: fully opaque
|
|
188
188
|
|
|
189
189
|
Raises:
|
|
190
|
-
ValueError: If
|
|
191
|
-
and `1.0` inclusive.
|
|
190
|
+
ValueError: If it is not between `0.0` and `1.0` inclusive.
|
|
192
191
|
"""
|
|
193
192
|
|
|
194
193
|
title_text_style: Optional[TextStyle] = None
|