[Question] [Navigation and routing] how to append data to the browser of other computer ? #3090
-
QuestionI have two computer in same network. When I click a button on "A" computer, I want to add data to a data table on my computer. Code sampleimport flet as ft
def main(page: ft.Page):
data_table_sample=ft.DataTable(
width=400,
bgcolor="yellow",
border=ft.border.all(2, "red"),
border_radius=10,
vertical_lines=ft.border.BorderSide(3, "blue"),
horizontal_lines=ft.border.BorderSide(1, "green"),
sort_column_index=0,
sort_ascending=True,
heading_row_color=ft.colors.BLACK12,
heading_row_height=100,
data_row_color={"hovered": "0x30FF0000"},
show_checkbox_column=True,
divider_thickness=0,
column_spacing=200,
columns=[
ft.DataColumn(
ft.Text("Column 1"),
),
ft.DataColumn(
ft.Text("Column 2"),
tooltip="This is a second column",
numeric=True,
),
],
rows=[
ft.DataRow([ft.DataCell(ft.Text("A")), ft.DataCell(ft.Text("1"))]),
],
)
def add_data_1(e):
data_table_sample.rows.append(
ft.DataRow(
cells=[
ft.DataRow([ft.DataCell(ft.Text("B")), ft.DataCell(ft.Text("2"))])
],
)
)
print("appended data_1 !!")
page.update()
def add_data_2(e):
data_table_sample.rows.append(
ft.DataRow(
cells=[
ft.DataRow([ft.DataCell(ft.Text("C")), ft.DataCell(ft.Text("3"))])
],
)
)
print("appended data_2 !!")
page.update()
def route_change(route):
global message
page.views.clear()
page.views.append(
ft.View(
"/",
[
ft.ElevatedButton(text="add_data", on_click = add_data_1, data = "add_data"),
],
)
)
if page.route == "/data_table":
page.views.append(
ft.View(
"/data_table",
[
ft.ElevatedButton(text="add_data", on_click = add_data_2, data = "add_data"),
data_table_sample
],
)
)
page.update()
def view_pop(view):
page.views.pop()
top_view = page.views[-1]
page.go(top_view.route)
page.on_route_change = route_change
page.on_view_pop = view_pop
page.go(page.route)
ft.app(target=main, host="192.168.35.35", port= 8550, view=ft.AppView.WEB_BROWSER)
host="192.168.35.35" --> it is my ip-address Error messagen/a ------------------------------------------------------
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
import flet as ft def main(page: ft.Page):
ft.app(target=main, host="10.0.0.45", port= 8550, view=ft.AppView.WEB_BROWSER) #host="192.168.35.35" --> it is my ip-address |
Beta Was this translation helpful? Give feedback.
import flet as ft
def main(page: ft.Page):