Relative Content

Tag Archive for pythonflutterflet

“Control must be added” even though it exists on the page in flet

import flet as ft from reusable_controls import CustomControl, PathControl path_control = PathControl(“Enter Source Path”, “Find”) path_control_2 = PathControl(“Enter Destination Path”, “Browse”) home_controls = ft.Column( spacing=10, expand=True, controls=[path_control, path_control_2, ft.Container( alignment=ft.alignment.Alignment(0, 0), content=ft.ElevatedButton( content=ft.Text(value=”Run”, size=20), width=150, height=50, style=ft.ButtonStyle( shape=ft.RoundedRectangleBorder(radius=10), ), ), ), ft.Divider(height=10), ft.Column( expand=True, width=800, scroll=ft.ScrollMode.ALWAYS, spacing=10, controls=[CustomControl(“Path”) for _ in range(20)], ), ], ) […]

How to automatically resize and reposition controls when the window is resized?

I’m trying to develop a scratch app with Python Flet. My goal is to find a way to position, or alternatively, to specify controls dimensions relatively to their parent control dimensions. For example, a button width of 70% the container width which is, in turn, the 30% of the page width. In this way, every control dimensions is resized automatically when the page is resized by the user, remaining in the same proportions.
I found interesting this property, but when I reduce the window size something still doesn’t work. I would like that each control in the page reduces its dimensions proportionally according to the window size.