[Python] How to alignment element of page.overlay[] list?

Discussão em 'Python' iniciado por Stack, Março 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have an flet.Container() object, that appending to page.overlay. Then I want to show it, by page.update(). But it align by default: start, start(top-left corner). It should align bottom-center as I want.

    I was trying align elements on page by

    page.vertical_alignment = 'start'
    page.horizontal_alignment = 'center'


    no results, cuz I writing questions rn.

    P.S. I bet 100%, there is no people who need it, or gonna check this question, but I leave my full code here:

    import flet as ft

    def main(page : ft.Page):
    def keyboard():
    vk = ft.Container(
    content=ft.Column(
    controls=[
    ft.Row([ft.OutlinedButton('O', width=120, height=70) for i in range(12)], spacing=25),
    ft.Row([ft.OutlinedButton('O', width=120, height=70) for i in range(12)], spacing=25),
    ft.Row([ft.OutlinedButton('O', width=120, height=70) for i in range(12)], spacing=25),
    ft.Row([ft.OutlinedButton('O', width=120, height=70) for i in range(12)], spacing=25),
    ],
    expand=True,
    spacing=25,
    ),
    bgcolor='teal.5',
    width=page.window.width,
    border=ft.border.all(4, 'teal'),
    border_radius=ft.border_radius.all(5),
    alignment=ft.alignment.bottom_center
    )
    return vk


    page.window.full_screen = True
    page.vertical_alignment = 'start'
    page.horizontal_alignment = 'center'
    page.padding = 0
    page.theme = ft.Theme(color_scheme_seed=ft.Colors.GREEN)




    def onbl(e):
    page.overlay.pop(0)
    page.update()

    def oncl(e):
    kb = keyboard()
    page.overlay.append(kb)
    page.update()


    tf = ft.TextField(
    label='Тыкни',
    on_focus=oncl,
    on_blur=onbl,
    )

    page.add( ft.VerticalDivider(), tf)


    ft.app(main)

    Continue reading...

Compartilhe esta Página