flet: Page.window_destroy very slow

import flet


def main(page: flet.Page):
    def quit_window(e):
        page.window_destroy()
    page.add(flet.TextButton(text='quit', on_click=quit_window))


flet.app(target=main)

It takes ~5 second to destory the window, frozen during that period. Is that possible to speed up that process?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (6 by maintainers)

Most upvoted comments

For desktop apps “fletd” in Golang using webservices was replaced with a light-weight Fletd shim written in Python. There is a little latency right now and Python code is not “flooding” with a lot of window events when you move it, resize it, etc.

Yep. It was 300 ms throttling, now it’s 0.

But what if, in the button’s on_click event callback, you try to hide the window first…then destroy it. Have you tried?

Yes and it works. My initial concern is it may slow down things in a loop. Then I realized I shouldn’t be coding that way, since only a single window is supported and I shouldn’t create and destroy it many times.

No, sys.exit() doesn’t quit the script at all.

Also, the window may need to be reopened, by let’s say a system tray icon. Now I’m using page.window_visible to hide the window instead of destroying it as a more proper way, but it hurts the exiting speed nevertheless.

So maybe you can add hiding to the beginning of page.window_destroy() , and let it quit quietly?