I am getting different results with same code on different PCs (windows 11) . (using flet -version 0.3.2) #805
-
Getting the desired output as by pressing the "START" button, the controls of "left_column" get appended with a container named "c".And as it is visible in the image below, a new container gets rendered below the previous one. But, using the exact same code on my other PC, No matter how many times i click on the "START" button, the container "c" with text appears only one time.Even if my way of implementing stuffs is not correct, it should still result in the same output and functioning on different PCs. |
Beta Was this translation helpful? Give feedback.
Answered by
FeodorFitsner
Jan 5, 2023
Replies: 1 comment 1 reply
-
Could be different versions of Flet package installed. Anyway, you can't add the same instance of control into the page - each control must be unique. This is the corrected code: # import platform
# from flet.border import Border, BorderSide
import flet as ft
def m(page: ft.Page):
def click_handler(e):
print("button pressed")
left_column.controls.append(
ft.Container(
content=ft.Text("Random Text"),
border_radius=10,
bgcolor=ft.colors.AMBER_400,
padding=3,
)
)
left_column.update()
print("updated\n")
# add/update controls on Page
page.theme_mode = "light"
# page.auto_scroll = True
# page.scroll = ft.ScrollMode.ALWAYS
page.window_height = 400
page.window_width = 800
page.appbar = ft.AppBar(
title=ft.Text("TEST APP"),
center_title=True,
bgcolor=ft.colors.BLUE,
color=ft.colors.WHITE,
)
start_bt = ft.ElevatedButton(text="START", on_click=click_handler)
page.add(ft.Row(controls=[start_bt], alignment=ft.MainAxisAlignment.CENTER))
left_column = ft.Column(
width=500, height=600, scroll=ft.ScrollMode.ALWAYS, auto_scroll=True
)
page.add(
ft.Container(
content=left_column,
)
)
page.update()
if __name__ == "__main__":
print("starting gui")
ft.app(target=m) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dynstat
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could be different versions of Flet package installed.
Anyway, you can't add the same instance of control into the page - each control must be unique.
This is the corrected code: