pyflutter-ui 0.1.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.
- pyflutter_ui/__init__.py +89 -0
- pyflutter_ui/app.py +295 -0
- pyflutter_ui/config_app.py +185 -0
- pyflutter_ui/file_picker.py +274 -0
- pyflutter_ui/navigator.py +94 -0
- pyflutter_ui/scheduler.py +154 -0
- pyflutter_ui/system_theme.py +80 -0
- pyflutter_ui/table_widget.py +160 -0
- pyflutter_ui/theme.py +1066 -0
- pyflutter_ui/ui/__init__.py +78 -0
- pyflutter_ui/ui/buttons.py +351 -0
- pyflutter_ui/ui/container.py +125 -0
- pyflutter_ui/ui/core.py +890 -0
- pyflutter_ui/ui/list_builder.py +390 -0
- pyflutter_ui/ui/progress.py +123 -0
- pyflutter_ui/ui/tables.py +119 -0
- pyflutter_ui/ui/widgets.py +1283 -0
- pyflutter_ui-0.1.0.dist-info/METADATA +101 -0
- pyflutter_ui-0.1.0.dist-info/RECORD +20 -0
- pyflutter_ui-0.1.0.dist-info/WHEEL +4 -0
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from .core import (
|
|
2
|
+
Element,
|
|
3
|
+
FlutterWidget,
|
|
4
|
+
StatefulElement,
|
|
5
|
+
StatefulWidget,
|
|
6
|
+
StatelessElement,
|
|
7
|
+
BuildContext,
|
|
8
|
+
BaseMaterialApp,
|
|
9
|
+
ChangeNotifier,
|
|
10
|
+
CommandNotifier,
|
|
11
|
+
Consumer,
|
|
12
|
+
ConsumerElement,
|
|
13
|
+
ConsumerState,
|
|
14
|
+
GlobalKey,
|
|
15
|
+
Disposable,
|
|
16
|
+
inflate_widget,
|
|
17
|
+
InheritedWidget,
|
|
18
|
+
LayoutData,
|
|
19
|
+
Navigator,
|
|
20
|
+
Provider,
|
|
21
|
+
StatelessWidget,
|
|
22
|
+
RenderObject,
|
|
23
|
+
State,
|
|
24
|
+
ValueListenableBuilder,
|
|
25
|
+
ValueNotifier,
|
|
26
|
+
PageApp,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
from .buttons import (
|
|
30
|
+
Container,
|
|
31
|
+
ExpandedElement,
|
|
32
|
+
FlexibleElement,
|
|
33
|
+
Flexible,
|
|
34
|
+
Spacer,
|
|
35
|
+
Expanded,
|
|
36
|
+
ElevatedButton,
|
|
37
|
+
DropdownButton,
|
|
38
|
+
FloatingActionButton,
|
|
39
|
+
TextInput,
|
|
40
|
+
TextEditingController,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
from .list_builder import (
|
|
44
|
+
ListBuilder,
|
|
45
|
+
ScrollableColumn,
|
|
46
|
+
ScrollableColumnOrProgress,
|
|
47
|
+
ScrollView,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
from .container import Container, SizedBox
|
|
51
|
+
from .tables import TableView
|
|
52
|
+
from .progress import LinearProgress, CircularProgress
|
|
53
|
+
|
|
54
|
+
from .widgets import (
|
|
55
|
+
NavigatorApp,
|
|
56
|
+
RenderObject,
|
|
57
|
+
TkMaterialApp,
|
|
58
|
+
Align,
|
|
59
|
+
Card,
|
|
60
|
+
Center,
|
|
61
|
+
Column,
|
|
62
|
+
Row,
|
|
63
|
+
Checkbox,
|
|
64
|
+
CrossAxisAlignment,
|
|
65
|
+
MainAxisAlignment,
|
|
66
|
+
AlignElement,
|
|
67
|
+
AppBar,
|
|
68
|
+
BottomNavigationBar,
|
|
69
|
+
Divider,
|
|
70
|
+
Drawer,
|
|
71
|
+
Icon,
|
|
72
|
+
IconButton,
|
|
73
|
+
Padding,
|
|
74
|
+
Image,
|
|
75
|
+
Scaffold,
|
|
76
|
+
Text,
|
|
77
|
+
Alignment,
|
|
78
|
+
)
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
# buttons.py
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
from typing import Any, Callable
|
|
4
|
+
from tkinter import ttk
|
|
5
|
+
import tkinter as tk
|
|
6
|
+
|
|
7
|
+
from pyflutter_ui.ui.core import (
|
|
8
|
+
FlutterWidget,
|
|
9
|
+
BuildContext,
|
|
10
|
+
Element,
|
|
11
|
+
GlobalKey,
|
|
12
|
+
StatelessWidget,
|
|
13
|
+
tkWidgetType,
|
|
14
|
+
ChangeNotifier,
|
|
15
|
+
)
|
|
16
|
+
from pyflutter_ui.ui.container import Container
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# ============================================================
|
|
20
|
+
# FLEX
|
|
21
|
+
# ============================================================
|
|
22
|
+
class Expanded[E: ExpandedElement](StatelessWidget):
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self, child: FlutterWidget, flex: int = 1, *, key: GlobalKey | None = None
|
|
26
|
+
) -> None:
|
|
27
|
+
super().__init__(key)
|
|
28
|
+
|
|
29
|
+
self.child = child
|
|
30
|
+
self.flex = flex
|
|
31
|
+
|
|
32
|
+
def create_element(self) -> ExpandedElement:
|
|
33
|
+
return ExpandedElement(self)
|
|
34
|
+
|
|
35
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
36
|
+
return self.child
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class ExpandedElement[F: Expanded, T: tkWidgetType](Element):
|
|
40
|
+
|
|
41
|
+
def __init__(self, widget: Expanded) -> None:
|
|
42
|
+
super().__init__(widget)
|
|
43
|
+
self._child_element: Element | None = None
|
|
44
|
+
|
|
45
|
+
def get_widget_flutter(self) -> Expanded:
|
|
46
|
+
return self.widget_flutter
|
|
47
|
+
|
|
48
|
+
def mount(self, context: BuildContext) -> T:
|
|
49
|
+
super().mount(context)
|
|
50
|
+
child_element: Element = self.get_widget_flutter().child.create_element()
|
|
51
|
+
|
|
52
|
+
child_element.layout_data.flex = self.get_widget_flutter().flex
|
|
53
|
+
child_element.layout_data.expand = True
|
|
54
|
+
widget = child_element.mount(context)
|
|
55
|
+
|
|
56
|
+
self._child_element = child_element # <-- faltava
|
|
57
|
+
self.render_object = child_element.render_object
|
|
58
|
+
self.widget_tk = widget
|
|
59
|
+
return widget
|
|
60
|
+
|
|
61
|
+
def unmount(self) -> None:
|
|
62
|
+
if self._child_element is not None:
|
|
63
|
+
self._child_element.unmount()
|
|
64
|
+
self._child_element = None
|
|
65
|
+
super().unmount()
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
class Flexible(Expanded):
|
|
69
|
+
|
|
70
|
+
def __init__(
|
|
71
|
+
self, child: FlutterWidget, flex: int = 1, *, key: GlobalKey | None = None
|
|
72
|
+
) -> None:
|
|
73
|
+
super().__init__(child, flex, key=key)
|
|
74
|
+
|
|
75
|
+
def create_element(self) -> FlexibleElement:
|
|
76
|
+
return FlexibleElement(self)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
class FlexibleElement(ExpandedElement):
|
|
80
|
+
|
|
81
|
+
EXPAND = False
|
|
82
|
+
|
|
83
|
+
def __init__(self, widget: Flexible) -> None:
|
|
84
|
+
super().__init__(widget)
|
|
85
|
+
|
|
86
|
+
def get_widget_flutter(self) -> Flexible:
|
|
87
|
+
return self.widget_flutter
|
|
88
|
+
|
|
89
|
+
def mount(self, context: BuildContext) -> tk.Widget:
|
|
90
|
+
super().mount(context)
|
|
91
|
+
self._child_element.layout_data.expand = False
|
|
92
|
+
return self.widget_tk
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Spacer(Expanded):
|
|
96
|
+
|
|
97
|
+
def __init__(
|
|
98
|
+
self, child: FlutterWidget, flex: int = 1, *, key: GlobalKey | None = None
|
|
99
|
+
) -> None:
|
|
100
|
+
super().__init__(child, flex, key=key)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# ============================================================
|
|
104
|
+
# ELEVATED BUTTON
|
|
105
|
+
# ============================================================
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
class ElevatedButton(StatelessWidget):
|
|
109
|
+
|
|
110
|
+
def __init__(
|
|
111
|
+
self, text: str, on_pressed: Callable[[], None], *, key: GlobalKey | None = None
|
|
112
|
+
) -> None:
|
|
113
|
+
super().__init__(key)
|
|
114
|
+
|
|
115
|
+
self.text = text
|
|
116
|
+
self.on_pressed = on_pressed
|
|
117
|
+
|
|
118
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
119
|
+
return self
|
|
120
|
+
|
|
121
|
+
def create_element(self) -> ElevatedButtonElement:
|
|
122
|
+
return ElevatedButtonElement(self)
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class ElevatedButtonElement[F: ElevatedButton, T: ttk.Button](Element):
|
|
126
|
+
|
|
127
|
+
def __init__(self, widget: ElevatedButton) -> None:
|
|
128
|
+
super().__init__(widget)
|
|
129
|
+
|
|
130
|
+
def get_widget_flutter(self) -> ElevatedButton:
|
|
131
|
+
return super().get_widget_flutter()
|
|
132
|
+
|
|
133
|
+
def get_widget_tk(self) -> ttk.Button:
|
|
134
|
+
return super().get_widget_tk()
|
|
135
|
+
|
|
136
|
+
def mount(self, context: BuildContext) -> ttk.Button:
|
|
137
|
+
super().mount(context)
|
|
138
|
+
self.widget_tk = ttk.Button(
|
|
139
|
+
context.parent_tk_widget,
|
|
140
|
+
text=self.get_widget_flutter().text,
|
|
141
|
+
command=self.get_widget_flutter().on_pressed,
|
|
142
|
+
)
|
|
143
|
+
# fill="both" garante que o botão preenche o wrapper
|
|
144
|
+
# que o FlexRenderObject controla via grid
|
|
145
|
+
self.widget_tk.pack(fill="both", expand=True)
|
|
146
|
+
return self.widget_tk
|
|
147
|
+
|
|
148
|
+
def update(self, new_widget: FlutterWidget) -> None:
|
|
149
|
+
super().update(new_widget)
|
|
150
|
+
if self.widget_tk is not None:
|
|
151
|
+
self.get_widget_tk().configure(
|
|
152
|
+
text=self.get_widget_flutter().text,
|
|
153
|
+
command=self.get_widget_flutter().on_pressed,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
# ============================================================
|
|
158
|
+
# DROPDOWN BUTTON
|
|
159
|
+
# ============================================================
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class DropdownButton(StatelessWidget):
|
|
163
|
+
|
|
164
|
+
def __init__(
|
|
165
|
+
self,
|
|
166
|
+
items: list[str],
|
|
167
|
+
value: str | None = None,
|
|
168
|
+
*,
|
|
169
|
+
on_changed: Callable[[str], None] | None = None,
|
|
170
|
+
key: GlobalKey | None = None,
|
|
171
|
+
) -> None:
|
|
172
|
+
super().__init__(key)
|
|
173
|
+
|
|
174
|
+
self.items = items
|
|
175
|
+
|
|
176
|
+
if value is None:
|
|
177
|
+
if len(self.items) > 0:
|
|
178
|
+
self.value = self.items[0]
|
|
179
|
+
else:
|
|
180
|
+
self.value = ""
|
|
181
|
+
else:
|
|
182
|
+
self.value = value
|
|
183
|
+
|
|
184
|
+
self.on_changed = on_changed
|
|
185
|
+
|
|
186
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
187
|
+
return self
|
|
188
|
+
|
|
189
|
+
def create_element(self) -> Element:
|
|
190
|
+
return DropdownButtonElement(self)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class DropdownButtonElement(Element[DropdownButton, ttk.Combobox]):
|
|
194
|
+
|
|
195
|
+
def __init__(self, widget: DropdownButton) -> None:
|
|
196
|
+
super().__init__(widget)
|
|
197
|
+
self.variable: tk.StringVar = tk.StringVar(value=widget.value)
|
|
198
|
+
|
|
199
|
+
def get_widget_flutter(self) -> DropdownButton:
|
|
200
|
+
return self.widget_flutter
|
|
201
|
+
|
|
202
|
+
def get_widget_tk(self) -> ttk.Combobox:
|
|
203
|
+
return super().get_widget_tk()
|
|
204
|
+
|
|
205
|
+
def update(self, new_widget: FlutterWidget) -> None:
|
|
206
|
+
super().update(new_widget)
|
|
207
|
+
self.get_widget_tk().set(self.get_widget_flutter().value)
|
|
208
|
+
self.get_widget_tk()["values"] = self.get_widget_flutter().items
|
|
209
|
+
|
|
210
|
+
def mount(self, context: BuildContext) -> ttk.Combobox:
|
|
211
|
+
super().mount(context)
|
|
212
|
+
|
|
213
|
+
combo = ttk.Combobox(
|
|
214
|
+
context.parent_tk_widget,
|
|
215
|
+
textvariable=self.variable,
|
|
216
|
+
values=self.get_widget_flutter().items,
|
|
217
|
+
)
|
|
218
|
+
combo.set(self.get_widget_flutter().value)
|
|
219
|
+
combo.pack(fill="x")
|
|
220
|
+
|
|
221
|
+
# Força o Tk processar o layout antes de setar o valor
|
|
222
|
+
combo.update_idletasks()
|
|
223
|
+
|
|
224
|
+
if self.get_widget_flutter().on_changed:
|
|
225
|
+
combo.bind(
|
|
226
|
+
"<<ComboboxSelected>>",
|
|
227
|
+
lambda e: self.get_widget_flutter().on_changed(self.variable.get()),
|
|
228
|
+
)
|
|
229
|
+
self.widget_tk = combo
|
|
230
|
+
return combo
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
# ============================================================
|
|
234
|
+
# FLOATING ACTION BUTTON
|
|
235
|
+
# ============================================================
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
class FloatingActionButton(ElevatedButton):
|
|
239
|
+
|
|
240
|
+
def __init__(
|
|
241
|
+
self, text: str, on_pressed: Callable[[], None], *, key: GlobalKey | None = None
|
|
242
|
+
) -> None:
|
|
243
|
+
super().__init__(text, on_pressed, key=key)
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
# ============================================================
|
|
247
|
+
# TextEditingController + TextInput (campo de texto controlado)
|
|
248
|
+
# ============================================================
|
|
249
|
+
class TextEditingController(ChangeNotifier):
|
|
250
|
+
"""Equivalente ao TextEditingController do Flutter."""
|
|
251
|
+
|
|
252
|
+
def __init__(self, text: str = "") -> None:
|
|
253
|
+
super().__init__()
|
|
254
|
+
self._text: str = text
|
|
255
|
+
self._focus: Callable[[], None] | None = None
|
|
256
|
+
|
|
257
|
+
@property
|
|
258
|
+
def text(self) -> str:
|
|
259
|
+
return self._text
|
|
260
|
+
|
|
261
|
+
@text.setter
|
|
262
|
+
def text(self, value: str) -> None:
|
|
263
|
+
self._text = value
|
|
264
|
+
self.notify_listeners()
|
|
265
|
+
|
|
266
|
+
def set_silent(self, value: str) -> None:
|
|
267
|
+
"""Atualiza sem notificar (usado pelo próprio campo ao digitar)."""
|
|
268
|
+
self._text = value
|
|
269
|
+
|
|
270
|
+
def clear(self) -> None:
|
|
271
|
+
self.text = ""
|
|
272
|
+
|
|
273
|
+
def bind_focus(self, fn: Callable[[], None] | None) -> None:
|
|
274
|
+
self._focus = fn
|
|
275
|
+
|
|
276
|
+
def request_focus(self) -> None:
|
|
277
|
+
if self._focus is not None:
|
|
278
|
+
self._focus()
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
class TextInput(StatelessWidget):
|
|
282
|
+
|
|
283
|
+
def __init__(
|
|
284
|
+
self,
|
|
285
|
+
controller: TextEditingController,
|
|
286
|
+
*,
|
|
287
|
+
width: int = 14,
|
|
288
|
+
on_submitted: Callable[[], None] | None = None,
|
|
289
|
+
key: GlobalKey | None = None,
|
|
290
|
+
) -> None:
|
|
291
|
+
super().__init__(key)
|
|
292
|
+
|
|
293
|
+
self.controller: TextEditingController = controller
|
|
294
|
+
self.width: int = width
|
|
295
|
+
self.on_submitted: Callable[[], None] | None = on_submitted
|
|
296
|
+
|
|
297
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
298
|
+
return self
|
|
299
|
+
|
|
300
|
+
def create_element(self) -> Element:
|
|
301
|
+
return TextInputElement(self)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
class TextInputElement(Element[TextInput, ttk.Entry]):
|
|
305
|
+
|
|
306
|
+
def __init__(self, widget: TextInput) -> None:
|
|
307
|
+
super().__init__(widget)
|
|
308
|
+
self._var: tk.StringVar | None = None
|
|
309
|
+
|
|
310
|
+
def get_widget_flutter(self) -> TextInput:
|
|
311
|
+
return self.widget_flutter # type: ignore[return-value]
|
|
312
|
+
|
|
313
|
+
def mount(self, context: BuildContext) -> ttk.Entry:
|
|
314
|
+
super().mount(context)
|
|
315
|
+
w = self.get_widget_flutter()
|
|
316
|
+
var = tk.StringVar(value=w.controller.text)
|
|
317
|
+
entry = ttk.Entry(context.parent_tk_widget, textvariable=var, width=w.width)
|
|
318
|
+
entry.pack(fill="x")
|
|
319
|
+
|
|
320
|
+
self._var = var
|
|
321
|
+
var.trace_add("write", self._on_var)
|
|
322
|
+
w.controller.add_listener(self._on_controller)
|
|
323
|
+
|
|
324
|
+
def focus() -> None:
|
|
325
|
+
entry.focus_set()
|
|
326
|
+
entry.selection_range(0, "end")
|
|
327
|
+
|
|
328
|
+
w.controller.bind_focus(focus)
|
|
329
|
+
|
|
330
|
+
if w.on_submitted is not None:
|
|
331
|
+
callback = w.on_submitted
|
|
332
|
+
entry.bind("<Return>", lambda _e: callback())
|
|
333
|
+
|
|
334
|
+
self.widget_tk = entry
|
|
335
|
+
return entry
|
|
336
|
+
|
|
337
|
+
def _on_var(self, *_: object) -> None:
|
|
338
|
+
if self._var is not None:
|
|
339
|
+
self.get_widget_flutter().controller.set_silent(self._var.get())
|
|
340
|
+
|
|
341
|
+
def _on_controller(self) -> None:
|
|
342
|
+
ctrl = self.get_widget_flutter().controller
|
|
343
|
+
if self._var is not None and self._var.get() != ctrl.text:
|
|
344
|
+
self._var.set(ctrl.text)
|
|
345
|
+
|
|
346
|
+
def unmount(self) -> None:
|
|
347
|
+
ctrl = self.get_widget_flutter().controller
|
|
348
|
+
ctrl.remove_listener(self._on_controller)
|
|
349
|
+
ctrl.bind_focus(None)
|
|
350
|
+
self._var = None
|
|
351
|
+
super().unmount()
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# container.py
|
|
2
|
+
from __future__ import annotations
|
|
3
|
+
import tkinter as tk
|
|
4
|
+
from tkinter import ttk
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from pyflutter_ui.ui.core import (
|
|
8
|
+
FlutterWidget,
|
|
9
|
+
BuildContext,
|
|
10
|
+
Element,
|
|
11
|
+
GlobalKey,
|
|
12
|
+
StatelessWidget,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# ============================================================
|
|
17
|
+
# SIZED BOX
|
|
18
|
+
# ============================================================
|
|
19
|
+
class SizedBox(StatelessWidget):
|
|
20
|
+
|
|
21
|
+
def __init__(
|
|
22
|
+
self,
|
|
23
|
+
width: int | None = None,
|
|
24
|
+
height: int | None = None,
|
|
25
|
+
*,
|
|
26
|
+
key: GlobalKey | None = None,
|
|
27
|
+
) -> None:
|
|
28
|
+
super().__init__(key)
|
|
29
|
+
|
|
30
|
+
self.width = width
|
|
31
|
+
self.height = height
|
|
32
|
+
|
|
33
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
def create_element(self) -> Element:
|
|
37
|
+
return SizedBoxElement(self)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SizedBoxElement(Element):
|
|
41
|
+
|
|
42
|
+
def __init__(self, widget: SizedBox) -> None:
|
|
43
|
+
super().__init__(widget)
|
|
44
|
+
|
|
45
|
+
def get_widget_flutter(self) -> SizedBox:
|
|
46
|
+
return self.widget_flutter
|
|
47
|
+
|
|
48
|
+
def mount(self, context: BuildContext) -> tk.Widget:
|
|
49
|
+
|
|
50
|
+
frame = ttk.Frame(context.parent_tk_widget)
|
|
51
|
+
|
|
52
|
+
if self.get_widget_flutter().width:
|
|
53
|
+
frame.configure(width=self.get_widget_flutter().width)
|
|
54
|
+
|
|
55
|
+
if self.get_widget_flutter().height:
|
|
56
|
+
frame.configure(height=self.get_widget_flutter().height)
|
|
57
|
+
|
|
58
|
+
frame.pack_propagate(False)
|
|
59
|
+
frame.pack()
|
|
60
|
+
self.widget_tk = frame
|
|
61
|
+
return frame
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# ============================================================
|
|
65
|
+
# CONTAINER
|
|
66
|
+
# ============================================================
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class Container(StatelessWidget):
|
|
70
|
+
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
child: Optional[FlutterWidget] = None,
|
|
74
|
+
width: int | None = None,
|
|
75
|
+
height: int | None = None,
|
|
76
|
+
padding: int = 0,
|
|
77
|
+
*,
|
|
78
|
+
key: GlobalKey | None = None,
|
|
79
|
+
) -> None:
|
|
80
|
+
super().__init__(key)
|
|
81
|
+
|
|
82
|
+
self.child = child
|
|
83
|
+
self.width = width
|
|
84
|
+
self.height = height
|
|
85
|
+
self.padding = padding
|
|
86
|
+
|
|
87
|
+
def build(self, context: BuildContext) -> FlutterWidget:
|
|
88
|
+
return self
|
|
89
|
+
|
|
90
|
+
def create_element(self) -> Element:
|
|
91
|
+
return ContainerElement(self)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
class ContainerElement(Element[Container, ttk.Frame]):
|
|
95
|
+
|
|
96
|
+
def __init__(self, widget: Container) -> None:
|
|
97
|
+
super().__init__(widget)
|
|
98
|
+
|
|
99
|
+
def get_widget_flutter(self) -> Container:
|
|
100
|
+
return self.widget_flutter
|
|
101
|
+
|
|
102
|
+
def mount(self, context: BuildContext) -> ttk.Frame:
|
|
103
|
+
super().mount(context)
|
|
104
|
+
|
|
105
|
+
frame = ttk.Frame(context.parent_tk_widget)
|
|
106
|
+
|
|
107
|
+
if self.get_widget_flutter().width:
|
|
108
|
+
frame.configure(width=float(self.get_widget_flutter().width))
|
|
109
|
+
|
|
110
|
+
if self.get_widget_flutter().height:
|
|
111
|
+
frame.configure(height=float(self.widget_flutter.height))
|
|
112
|
+
|
|
113
|
+
frame.pack()
|
|
114
|
+
|
|
115
|
+
if self.get_widget_flutter().child:
|
|
116
|
+
child_element = self.get_widget_flutter().child.create_element()
|
|
117
|
+
|
|
118
|
+
child_context = BuildContext(
|
|
119
|
+
app=context.app, parent_widget=frame, parent_context=context
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
child_element.mount(child_context)
|
|
123
|
+
|
|
124
|
+
self.widget_tk = frame
|
|
125
|
+
return frame
|