I'm trying to implement a desktop application. However, I'm encountering some issues.
When I try to insert my data using the DataTable implementation, the layout of my data table may not appear at the top or the layout and length of the data table may affect the layout of other components after inserting the data.
If you know how to solve this problem, I would appreciate your advice or provide me with reference documentation. Thank you very much.
Here's the example code I wrote
import flet as ft
class MainWindow(UserControl):
def build(self):
self.Entry_URL = TextField(label = 'input keyword', width = 300)
searchLine = Row(spacing = 70, controls = [
ElevatedButton(text = 'btn1', on_click = self.startSpider),
ElevatedButton(text = 'btn2', disabled = True)])
ControlLine = Row(spacing = 70, controls = [
ElevatedButton(text = 'btn3'),
ElevatedButton(text = 'btn4', disabled = True)])
self.Table = DataTable(
columns = [DataColumn(Checkbox(label = 'Info')),
DataColumn(Text('col1')),
DataColumn(Text('col2')),
DataColumn(Text('col3')),
],
)
return Column(controls = [Row(controls = [self.Entry_URL, self.Table]), searchLine, ControlLine,
ElevatedButton(text = 'quit', width = 300), ], scroll = ft.ScrollMode.AUTO)
def startSpider(self, event):
# if (not self.Entry_URL.value):
# return
self.Table.rows.append(ft.DataRow(
cells = [
ft.DataCell(ft.Text("John", text_align = ft.TextAlign.CENTER)),
ft.DataCell(ft.Text("Smith", text_align = ft.TextAlign.CENTER)),
ft.DataCell(ft.Text("43", text_align = ft.TextAlign.CENTER)),
ft.DataCell(ft.Text("43", text_align = ft.TextAlign.CENTER), ),
],
),)
self.update()
def main(page:Page):
page.title = 'Test'
page.padding = 20
page.add(MainWindows())
ft.app(target = main)