Flet, applications with Flutter in Python

This seems very huge: making applications with Python instead of javascript with flet module to use Python for flutter. Let’s see the example provided in their site

import flet as ft

def main(page: ft.Page):
    page.title = "MY FIRST FLET APP"
    # aligned in the middle
    # page.vertical_alignment = ft.MainAxisAlignment.CENTER

    # the TextField widget
    txt_number = ft.TextField(
                        value="0",
                        text_align=ft.TextAlign.RIGHT,
                        width=100)


    def minus_click(e):
        txt_number.value = str(int(txt_number.value) - 1)
        page.update()

    def plus_click(e):
        txt_number.value = str(int(txt_number.value) + 1)
        page.update()

    # adds widgets to the page
    # 1 the - it's a button the second paramenter is the on_click command
    # 2 the textfield
    # 3 the +
    page.add(
        ft.Row(
            [
                ft.IconButton(ft.icons.REMOVE, on_click=minus_click),
                txt_number,
                ft.IconButton(ft.icons.ADD, on_click=plus_click),
            ],
            alignment=ft.MainAxisAlignment.CENTER,
        )
    )
# calling the main function with the target=main parameter for the flet.Page class
ft.app(target=main)

This makes a simple counter example. Very nice. We will see what we can make with it.

Examples repository

https://github.com/flet-dev/examples/tree/main/python


Subscribe to the newsletter for updates
Tkinter templates

Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Claude's Games

Arkanoid
Platform 2d

1. Memory game

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Advertisement