0

I am new to the Flet framework. I have noticed that while running some small apps, I see the Flet logo in the middle of the screen being animated while stuff is being loaded in the background. I want to know whether the logo can be changed and whether I can add some custom animations of my own?

Pranav Krishna S
  • 324
  • 2
  • 13

2 Answers2

1

the Flet logo can appear at 2 occasions and both can be modified to your liking.

  1. Splash at app entry: If you would like your app to load with a different splash image, check out this example app, that uses a custom image as a splash: https://github.com/flet-dev/examples/tree/main/python/apps/custom-loading-image.
  2. Loading indicator when something is run: This can be changed and controlled through the page.splash property, check out the snippet below that changes the flet loading thingy to a ProgressRing:
from time import sleep
import flet as ft

def main(page: ft.Page):
    def button_click(e):
        page.splash = ft.ProgressBar()
        btn.disabled = True
        page.update()
        sleep(3)
        page.splash = None
        btn.disabled = False
        page.update()

    btn = ft.ElevatedButton("Do some lengthy task!", on_click=button_click)
    page.add(btn)

ft.app(target=main)
Tim
  • 76
  • 3
1
  1. first create a folder in the folder that your main.py is located at and name it "assets"

See image here

  1. now inside the assets folder create another file called "icons" and put your logo picture in it but note that the name of the logo picture must be "loading-animation.png"

  2. now simply copy and paste this code in your main.py:

import flet
from flet import Page, Text


def main(page: Page):
    page.add(Text("Hello, world!"))


flet.app(target=main, assets_dir="assets", view=flet.WEB_BROWSER)

Hope this would be helpful.