responds-forms 0.4__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.
@@ -0,0 +1,27 @@
1
+ from .core import (
2
+ Element, FlutterWidget, StatefulElement, StatefulWidget, StatelessElement,
3
+ BuildContext, BaseMaterialApp, ChangeNotifier, CommandNotifier, Consumer,
4
+ ConsumerElement, ConsumerState, GlobalKey, Disposable, inflate_widget,
5
+ InheritedWidget, LayoutData, Navigator, Provider, StatelessWidget,
6
+ RenderObject, State, ValueListenableBuilder, ValueNotifier
7
+ )
8
+
9
+ from .buttons import (
10
+ Container, ExpandedElement, FlexibleElement, Flexible, Spacer, Expanded,
11
+ ElevatedButton, DropdownButton, FloatingActionButton,
12
+ )
13
+
14
+ from .list_builder import (
15
+ ListBuilder, ScrollableColumn, ScrollableColumnOrProgress, ScrollView
16
+ )
17
+
18
+ from .container import Container, SizedBox
19
+ from .tables import TableView
20
+ from .progress import LinearProgress, CircularProgress
21
+
22
+ from .widgets import (
23
+ NavigatorApp, RenderObject, TkMaterialApp, Align, Card, Center,
24
+ Column, Row, Checkbox, CrossAxisAlignment, MainAxisAlignment, AlignElement,
25
+ AppBar, BottomNavigationBar, Divider, Drawer, Icon, IconButton,
26
+ Padding, Image, Scaffold, Text, Alignment,
27
+ )
@@ -0,0 +1,219 @@
1
+ # buttons.py
2
+ from __future__ import annotations
3
+ from typing import Callable
4
+ from tkinter import ttk
5
+ import tkinter as tk
6
+
7
+ from pyflutter_ui.ui.core import (
8
+ FlutterWidget, BuildContext, Element, StatelessWidget
9
+ )
10
+
11
+ from pyflutter_ui.ui.container import Container
12
+
13
+ # ============================================================
14
+ # FLEX
15
+ # ============================================================
16
+ class Expanded(StatelessWidget):
17
+
18
+ def __init__(self, child: FlutterWidget, flex: int = 1) -> None:
19
+ super().__init__()
20
+ self.child = child
21
+ self.flex = flex
22
+
23
+ def create_element(self) -> ExpandedElement:
24
+ return ExpandedElement(self)
25
+
26
+ def build(self, context: BuildContext) -> FlutterWidget:
27
+ return self.child
28
+
29
+
30
+ class ExpandedElement(Element):
31
+
32
+ def __init__(self, widget: Expanded) -> None:
33
+ super().__init__(widget)
34
+ self._child_element: Element | None = None
35
+
36
+ def get_widget_flutter(self) -> Expanded:
37
+ return self.widget_flutter
38
+
39
+ def mount(self, context: BuildContext) -> tk.Widget:
40
+ super().mount(context)
41
+ child_element = self.get_widget_flutter().child.create_element()
42
+ child_element.layout_data.flex = self.get_widget_flutter().flex
43
+ child_element.layout_data.expand = True
44
+ widget = child_element.mount(context)
45
+
46
+ self.render_object = child_element.render_object
47
+ self.widget_tk = widget
48
+ return widget
49
+
50
+ def unmount(self) -> None:
51
+ if self._child_element is not None:
52
+ self._child_element.unmount()
53
+ self._child_element = None
54
+ super().unmount()
55
+
56
+
57
+ class Flexible(Expanded):
58
+
59
+ def __init__(self, child: FlutterWidget, flex: int = 1) -> None:
60
+ super().__init__(child, flex)
61
+
62
+ def create_element(self) -> FlexibleElement:
63
+ return FlexibleElement(self)
64
+
65
+
66
+ class FlexibleElement(ExpandedElement):
67
+
68
+ def __init__(self, widget: Flexible) -> None:
69
+ super().__init__(widget)
70
+
71
+ def get_widget_flutter(self) -> Flexible:
72
+ return self.widget_flutter
73
+
74
+ def mount(self, context: BuildContext) -> tk.Widget:
75
+ super().mount(context)
76
+ child_element = self.get_widget_flutter().child.create_element()
77
+ child_element.layout_data.flex = self.get_widget_flutter().flex
78
+ widget = child_element.mount(context)
79
+
80
+ self.render_object = child_element.render_object
81
+ self.widget_tk = widget
82
+ return widget
83
+
84
+
85
+ class Spacer(Expanded):
86
+
87
+ def __init__(self, flex: int = 1) -> None:
88
+ super().__init__(Container(), flex=flex)
89
+
90
+
91
+ # ============================================================
92
+ # ELEVATED BUTTON
93
+ # ============================================================
94
+
95
+ class ElevatedButton(StatelessWidget):
96
+
97
+ def __init__(self, text: str, on_pressed: Callable[[], None]) -> None:
98
+ super().__init__()
99
+ self.text = text
100
+ self.on_pressed = on_pressed
101
+
102
+ def build(self, context: BuildContext) -> FlutterWidget:
103
+ return self
104
+
105
+ def create_element(self) -> ElevatedButtonElement:
106
+ return ElevatedButtonElement(self)
107
+
108
+
109
+ class ElevatedButtonElement(Element[ttk.Button]):
110
+
111
+ def __init__(self, widget: ElevatedButton) -> None:
112
+ super().__init__(widget)
113
+
114
+ def get_widget_flutter(self) -> ElevatedButton:
115
+ return self.widget_flutter
116
+
117
+ def get_widget_tk(self) -> ttk.Button:
118
+ return super().get_widget_tk()
119
+
120
+ def mount(self, context: BuildContext) -> ttk.Button:
121
+ super().mount(context)
122
+ self.widget_tk = ttk.Button(
123
+ context.parent_tk_widget,
124
+ text=self.get_widget_flutter().text,
125
+ command=self.get_widget_flutter().on_pressed,
126
+ )
127
+ # fill="both" garante que o botão preenche o wrapper
128
+ # que o FlexRenderObject controla via grid
129
+ self.widget_tk.pack(fill="both", expand=True)
130
+ return self.widget_tk
131
+
132
+ def update(self, new_widget: FlutterWidget) -> None:
133
+ super().update(new_widget)
134
+ if self.widget_tk is not None:
135
+ self.get_widget_tk().configure(
136
+ text=self.get_widget_flutter().text,
137
+ command=self.get_widget_flutter().on_pressed,
138
+ )
139
+
140
+
141
+ # ============================================================
142
+ # DROPDOWN BUTTON
143
+ # ============================================================
144
+
145
+ class DropdownButton(StatelessWidget):
146
+
147
+ def __init__(
148
+ self,
149
+ items: list[str],
150
+ value: str | None = None, *,
151
+ on_changed: Callable[[str], None] | None = None
152
+ ) -> None:
153
+ super().__init__()
154
+ self.items = items
155
+
156
+ if value is None:
157
+ if len(self.items) > 0:
158
+ self.value = self.items[0]
159
+ else:
160
+ self.value = ""
161
+ else:
162
+ self.value = value
163
+
164
+ self.on_changed = on_changed
165
+
166
+ def build(self, context: BuildContext) -> FlutterWidget:
167
+ return self
168
+
169
+ def create_element(self) -> Element:
170
+ return DropdownButtonElement(self)
171
+
172
+
173
+ class DropdownButtonElement(Element[ttk.Combobox]):
174
+
175
+ def __init__(self, widget: DropdownButton) -> None:
176
+ super().__init__(widget)
177
+ self.variable: tk.StringVar = tk.StringVar(value=widget.value)
178
+
179
+ def get_widget_flutter(self) -> DropdownButton:
180
+ return self.widget_flutter
181
+
182
+ def get_widget_tk(self) -> ttk.Combobox:
183
+ return super().get_widget_tk()
184
+
185
+ def update(self, new_widget: FlutterWidget) -> None:
186
+ super().update(new_widget)
187
+ self.get_widget_tk().set(self.get_widget_flutter().value)
188
+ self.get_widget_tk()['values'] = self.get_widget_flutter().items
189
+
190
+ def mount(self, context: BuildContext) -> ttk.Combobox:
191
+ super().mount(context)
192
+
193
+ combo = ttk.Combobox(
194
+ context.parent_tk_widget,
195
+ textvariable=self.variable,
196
+ values=self.get_widget_flutter().items,
197
+ )
198
+ combo.set(self.get_widget_flutter().value)
199
+ combo.pack(fill="x")
200
+
201
+ # Força o Tk processar o layout antes de setar o valor
202
+ combo.update_idletasks()
203
+
204
+ if self.get_widget_flutter().on_changed:
205
+ combo.bind(
206
+ "<<ComboboxSelected>>", lambda e: self.get_widget_flutter().on_changed(self.variable.get())
207
+ )
208
+ self.widget_tk = combo
209
+ return combo
210
+
211
+
212
+ # ============================================================
213
+ # FLOATING ACTION BUTTON
214
+ # ============================================================
215
+
216
+ class FloatingActionButton(ElevatedButton):
217
+
218
+ def __init__(self, text: str, on_pressed: Callable[[], None]) -> None:
219
+ super().__init__(text, on_pressed)
@@ -0,0 +1,119 @@
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, BuildContext, Element, StatelessWidget
9
+ )
10
+
11
+
12
+ # ============================================================
13
+ # SIZED BOX
14
+ # ============================================================
15
+ class SizedBox(StatelessWidget):
16
+
17
+ def __init__(
18
+ self, width: int | None = None, height: int | None = None
19
+ ) -> None:
20
+ super().__init__()
21
+ self.width = width
22
+ self.height = height
23
+
24
+ def build(self, context: BuildContext) -> FlutterWidget:
25
+ return self
26
+
27
+ def create_element(self) -> Element:
28
+ return SizedBoxElement(self)
29
+
30
+
31
+ class SizedBoxElement(Element):
32
+
33
+ def __init__(self, widget: SizedBox) -> None:
34
+ super().__init__(widget)
35
+
36
+ def get_widget_flutter(self) -> SizedBox:
37
+ return self.widget_flutter
38
+
39
+ def mount(self, context: BuildContext) -> tk.Widget:
40
+
41
+ frame = ttk.Frame(context.parent_tk_widget)
42
+
43
+ if self.get_widget_flutter().width:
44
+ frame.configure(width=self.get_widget_flutter().width)
45
+
46
+ if self.get_widget_flutter().height:
47
+ frame.configure(height=self.get_widget_flutter().height)
48
+
49
+ frame.pack_propagate(False)
50
+ frame.pack()
51
+ self.widget_tk = frame
52
+ return frame
53
+
54
+
55
+ # ============================================================
56
+ # CONTAINER
57
+ # ============================================================
58
+
59
+ class Container(StatelessWidget):
60
+
61
+ def __init__(
62
+ self,
63
+ child: Optional[FlutterWidget] = None,
64
+ width: int | None = None,
65
+ height: int | None = None,
66
+ padding: int = 0
67
+ ) -> None:
68
+ super().__init__()
69
+
70
+ self.child = child
71
+ self.width = width
72
+ self.height = height
73
+ self.padding = padding
74
+
75
+ def build(self, context: BuildContext) -> FlutterWidget:
76
+ return self
77
+
78
+ def create_element(self) -> Element:
79
+ return ContainerElement(self)
80
+
81
+
82
+ class ContainerElement(Element[ttk.Frame]):
83
+
84
+ def __init__(self, widget: Container) -> None:
85
+ super().__init__(widget)
86
+
87
+ def get_widget_flutter(self) -> Container:
88
+ return self.widget_flutter
89
+
90
+ def mount(self, context: BuildContext) -> ttk.Frame:
91
+ super().mount(context)
92
+
93
+ frame = ttk.Frame(context.parent_tk_widget)
94
+
95
+ if self.get_widget_flutter().width:
96
+ frame.configure(width=float(self.get_widget_flutter().width))
97
+
98
+ if self.get_widget_flutter().height:
99
+ frame.configure(height=float(self.widget_flutter.height))
100
+
101
+ frame.pack()
102
+
103
+ if self.get_widget_flutter().child:
104
+ child_element = self.get_widget_flutter().child.create_element()
105
+
106
+ child_context = (
107
+ BuildContext(
108
+ app=context.app,
109
+ parent_widget=frame,
110
+ parent_context=context
111
+ )
112
+ )
113
+
114
+ child_element.mount(
115
+ child_context
116
+ )
117
+
118
+ self.widget_tk = frame
119
+ return frame