Skip to content

v0.1.53

Compare
Choose a tag to compare
@FeodorFitsner FeodorFitsner released this 27 Aug 17:48

Desktop Flet app can be started with a hidden window

New view=flet.FLET_APP_HIDDEN argument - run app with a hidden window on the startup. Window could be made visible from a user code:

import flet
from flet import Container, IconButton, Page, Row, Text, WindowDragArea, icons

def main(page: Page):
    page.add(
        Row(
            [
                WindowDragArea(
                    Container(
                        Text("This is a window move drag area."),
                        bgcolor="yellow",
                        padding=10,
                    ),
                    expand=1,
                ),
                IconButton(icon=icons.CLOSE, on_click=lambda _: page.window_close()),
            ]
        )
    )

    page.window_width = 600
    page.window_height = 400
    page.window_title_bar_hidden = True
    page.window_frameless = True
    page.window_visible = True
    page.window_center()

flet.app(target=main, view=flet.FLET_APP_HIDDEN)

New page properties to control window appearance and behavior

  • page.window_close()
  • page.window_title_bar_hidden
  • page.window_title_bar_buttons_hidden (macOS only)
  • page.window_skip_task_bar
  • page.window_frameless
  • page.window_progress_bar
  • page.window_visible

New WindowDragArea class to enable dragging/maximizing/restoring window without a title bar.

Other changes

New Stack properties:

  • Stack.clip_behavior - none, antiAlias, antiAliasWithSaveLayer, hardEdge.

Hot reload

For hot-reload run your Python program with flet command line:

usage: flet [-h] [--port PORT] [--directory] [--recursive] [--hidden] [--web] script

Runs Flet app in Python with hot reload.

positional arguments:
  script                path to a Python script

optional arguments:
  -h, --help            show this help message and exit
  --port PORT, -p PORT  custom TCP port to run Flet app on
  --directory, -d       watch script directory
  --recursive, -r       watch script directory and all sub-directories recursively       
  --hidden, -n          application window is hidden on startup
  --web, -w             open app in a web browser

By default, flet watches script file one. Use --directory flag to watch all files in script's directory. Use --recursive flag to watch script directory and all sub-directories recursively.

For example:

flet main.py -d

Platform details

New page properties:

  • web - True if the app running in the browser.
  • platform - operating system where the app is running: windows, macos, linux, ios and android.

Customisable route transitions

theme = Theme()
theme.page_transitions.android = "openUpwards"
theme.page_transitions.ios = "cupertino"
theme.page_transitions.macos = "fadeUpwards"
theme.page_transitions.linux = "zoom"
theme.page_transitions.windows = "zoom"
page.theme = theme

Possible values: fadeUpwards, openUpwards, zoom, cupertino.