How to change position of elements in Python Flet

I have a question regarding the container, for example I want to create one in a column and another in a row, however, when doing this it happens that the line does not start at the top of the layout, that is, it continues at the end of the column. I want to know if there is a way to resolve this, and so far I haven’t found anything in the documentation.

import flet as Ft


def main(Page: Ft.Page):
    Container = [Ft.Container(width=100, height=100, bgcolor="red"), 
                 Ft.Container(width=100, height=100, bgcolor="green"), 
                 Ft.Container(width=100, height=100, bgcolor="blue")]
    
    Container_1 = [Ft.Container(width=100, height=100, bgcolor="red"), 
                   Ft.Container(width=100, height=100, bgcolor="green"),
                   Ft.Container(width=100, height=100, bgcolor="blue")]
    
    Page.add(Ft.Column(spacing=0, controls=Container))
    Page.add(Ft.Row(spacing=0, controls=Container_1))

    Page.window_always_on_top = True
    #Page.window_width = 350
    #Page.window_height = 300
    Page.padding = 0
    Page.update()


Ft.app(target=main)

  • Try this: Page.add(Ft.Row([Ft.Column(spacing=0, controls=Container), Ft.Row(spacing=0, controls=Container_1)]))

    – 

  • Well, the result is better but it was positioned in the middle, not at the top.

    – 

  • I’m testing this lib, and I still don’t understand if such a thing is possible.

    – 

Leave a Comment