You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sdk/python/packages/flet/src/flet/controls/material/alert_dialog.py
+50-29Lines changed: 50 additions & 29 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
fromdataclassesimportfield
2
-
fromtypingimportList, Optional
2
+
fromtypingimportOptional
3
3
4
4
fromflet.controls.alignmentimportAlignment
5
5
fromflet.controls.base_controlimportcontrol
@@ -22,14 +22,18 @@
22
22
@control("AlertDialog")
23
23
classAlertDialog(DialogControl):
24
24
"""
25
-
An alert dialog informs the user about situations that require acknowledgement. An alert dialog has an optional title and an optional list of actions. The title is displayed above the content and the actions are displayed below the content.
25
+
An alert dialog informs the user about situations that require acknowledgement. An
26
+
alert dialog has an optional title and an optional list of actions. The title is
27
+
displayed above the content and the actions are displayed below the content.
The (optional) content of the dialog is displayed in the center of the dialog in a lighter font. Typically this is a [`Column`](https://flet.dev/docs/controls/column) that contains the dialog's [`Text`](https://flet.dev/docs/controls/text) message.
34
+
The (optional) content of the dialog is displayed in the center of the dialog in a
35
+
lighter font. Typically this is a [`Column`](https://flet.dev/docs/controls/column)
36
+
that contains the dialog's [`Text`](https://flet.dev/docs/controls/text) message.
33
37
34
38
Value is of type `Control`.
35
39
"""
@@ -43,21 +47,24 @@ class AlertDialog(DialogControl):
43
47
44
48
title: Optional[StrOrControl] =None
45
49
"""
46
-
The (optional) title of the dialog is displayed in a large font at the top of the dialog.
50
+
The (optional) title of the dialog is displayed in a large font at the top of the
51
+
dialog.
47
52
48
53
Typically a [`Text`](https://flet.dev/docs/controls/text) control.
The (optional) set of actions that are displayed at the bottom of the dialog.
54
59
55
-
Typically this is a list of [`TextButton`](https://flet.dev/docs/controls/textbutton) controls.
60
+
Typically this is a list of [`TextButton`](https://flet.dev/docs/controls/textbutton)
61
+
controls.
56
62
"""
57
63
58
64
bgcolor: OptionalColorValue=None
59
65
"""
60
-
The background [color](https://flet.dev/docs/reference/colors) of the dialog's surface.
66
+
The background [color](https://flet.dev/docs/reference/colors) of the dialog's
67
+
surface.
61
68
"""
62
69
63
70
elevation: OptionalNumber=None
@@ -69,7 +76,8 @@ class AlertDialog(DialogControl):
69
76
70
77
icon: Optional[Control] =None
71
78
"""
72
-
A control that is displayed at the top of the dialog. Typically a [`Icon`](https://flet.dev/docs/controls/icon) control.
79
+
A control that is displayed at the top of the dialog. Typically a [`Icon`](https://flet.dev/docs/controls/icon)
80
+
control.
73
81
"""
74
82
75
83
title_padding: OptionalPaddingValue=None
@@ -80,16 +88,20 @@ class AlertDialog(DialogControl):
80
88
81
89
Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
82
90
83
-
Defaults to providing `24` pixels on the top, left, and right of the title. If the `content` is not `None`, then no
84
-
bottom padding is provided (but see [`content_padding`](https://flet.dev/docs/reference/types/aliases#paddingvalue)).
85
-
If it is not set, then an extra `20` pixels of bottom padding is added to separate the title from the actions.
91
+
Defaults to providing `24` pixels on the top, left, and right of the title. If the
92
+
`content` is not `None`, then no bottom padding is provided (but see [`content_padding`](https://flet.dev/docs/reference/types/aliases#paddingvalue)).
93
+
If it is not set, then an extra `20` pixels of bottom padding is added to separate
94
+
the title from the actions.
86
95
"""
87
96
88
97
content_padding: OptionalPaddingValue=None
89
98
"""
90
99
Padding around the content.
91
100
92
-
If there is no content, no padding will be provided. Otherwise, padding of 20 pixels is provided above the content to separate the content from the title, and padding of 24 pixels is provided on the left, right, and bottom to separate the content from the other edges of the dialog.
101
+
If there is no content, no padding will be provided. Otherwise, padding of 20
102
+
pixels is provided above the content to separate the content from the title, and
103
+
padding of 24 pixels is provided on the left, right, and bottom to separate the
104
+
content from the other edges of the dialog.
93
105
94
106
Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
95
107
"""
@@ -98,9 +110,11 @@ class AlertDialog(DialogControl):
98
110
"""
99
111
Padding around the set of actions at the bottom of the dialog.
100
112
101
-
Typically used to provide padding to the button bar between the button bar and the edges of the dialog.
113
+
Typically used to provide padding to the button bar between the button bar and the
114
+
edges of the dialog.
102
115
103
-
If are no actions, then no padding will be included. The padding around the button bar defaults to zero.
116
+
If are no actions, then no padding will be included. The padding around the button
117
+
bar defaults to zero.
104
118
105
119
Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
106
120
"""
@@ -109,15 +123,16 @@ class AlertDialog(DialogControl):
109
123
"""
110
124
Defines the horizontal layout of the actions.
111
125
112
-
Value is of type [`MainAxisAlignment`](https://flet.dev/docs/reference/types/mainaxisalignment) and defaults to `MainAxisAlignment.END`.
126
+
Value is of type [`MainAxisAlignment`](https://flet.dev/docs/reference/types/mainaxisalignment)
127
+
and defaults to `MainAxisAlignment.END`.
113
128
"""
114
129
115
130
shape: Optional[OutlinedBorder] =None
116
131
"""
117
132
The shape of the dialog.
118
133
119
-
Value is of type [`OutlinedBorder`](https://flet.dev/docs/reference/types/outlinedborder) and defaults
120
-
to `RoundedRectangleBorder(radius=4.0)`.
134
+
Value is of type [`OutlinedBorder`](https://flet.dev/docs/reference/types/outlinedborder)
135
+
and defaults to `RoundedRectangleBorder(radius=4.0)`.
121
136
"""
122
137
123
138
inset_padding: OptionalPaddingValue=None
@@ -126,8 +141,8 @@ class AlertDialog(DialogControl):
126
141
127
142
Value is of type [`PaddingValue`](https://flet.dev/docs/reference/types/aliases#paddingvalue).
128
143
129
-
Defaults to `padding.symmetric(vertical=40, horizontal=24)` - 40 pixels horizontally and 24 pixels vertically outside of
130
-
the dialog box.
144
+
Defaults to `padding.symmetric(vertical=40, horizontal=24)` - 40 pixels
145
+
horizontally and 24 pixels vertically outside of the dialog box.
131
146
"""
132
147
133
148
icon_padding: OptionalPaddingValue=None
@@ -146,13 +161,14 @@ class AlertDialog(DialogControl):
146
161
147
162
surface_tint_color: OptionalColorValue=None
148
163
"""
149
-
The [color](https://flet.dev/docs/reference/colors) used as a surface tint overlay on the dialog's background color, which reflects the
150
-
dialog's elevation.
164
+
The [color](https://flet.dev/docs/reference/colors) used as a surface tint overlay
165
+
on the dialog's background color, which reflects the dialog's elevation.
151
166
"""
152
167
153
168
shadow_color: OptionalColorValue=None
154
169
"""
155
-
The [color](https://flet.dev/docs/reference/colors) used to paint a drop shadow under the dialog, which reflects the dialog's elevation.
170
+
The [color](https://flet.dev/docs/reference/colors) used to paint a drop shadow
171
+
under the dialog, which reflects the dialog's elevation.
156
172
"""
157
173
158
174
icon_color: OptionalColorValue=None
@@ -189,28 +205,33 @@ class AlertDialog(DialogControl):
189
205
"""
190
206
Controls how the contents of the dialog are clipped (or not) to the given `shape`.
191
207
192
-
Value is of type [`ClipBehavior`](https://flet.dev/docs/reference/types/clipbehavior) and defaults to `ClipBehavior.NONE`.
208
+
Value is of type [`ClipBehavior`](https://flet.dev/docs/reference/types/clipbehavior)
209
+
and defaults to `ClipBehavior.NONE`.
193
210
"""
194
211
195
212
semantics_label: Optional[str] =None
196
213
"""
197
-
The semantic label of the dialog used by accessibility frameworks to announce screen transitions when the dialog is opened and closed.
214
+
The semantic label of the dialog used by accessibility frameworks to announce
215
+
screen transitions when the dialog is opened and closed.
198
216
199
-
In iOS, if this label is not provided, a semantic label will be inferred from the `title` if it is not null.
217
+
In iOS, if this label is not provided, a semantic label will be inferred from the
218
+
`title` if it is not null.
200
219
201
220
Value is of type `str`.
202
221
"""
203
222
204
223
barrier_color: OptionalColorValue=None
205
224
"""
206
-
The [color](https://flet.dev/docs/reference/colors) of the modal barrier that darkens everything below the dialog.
225
+
The [color](https://flet.dev/docs/reference/colors) of the modal barrier that
226
+
darkens everything below the dialog.
207
227
208
-
If `None`, the [`DialogTheme.barrier_color`](https://flet.dev/docs/reference/types/dialogtheme#barrier_color) is used.
209
-
If it is also `None`, then `Colors.BLACK_54` is used.
228
+
If `None`, the [`DialogTheme.barrier_color`](https://flet.dev/docs/reference/types/dialogtheme#barrier_color)
229
+
is used. If it is also `None`, then `Colors.BLACK_54` is used.
210
230
"""
211
231
212
232
defbefore_update(self):
213
233
super().before_update()
214
234
assert (
215
235
self.titleorself.contentorself.actions
216
-
), "AlertDialog has nothing to display. Provide at minimum one of the following: title, content, actions"
236
+
), "AlertDialog has nothing to display. Provide at minimum one of the "
0 commit comments