flet icon indicating copy to clipboard operation
flet copied to clipboard

Window_maximized, window_minimized, window_close (), there is a very obvious delay after triggering the event.

Open FebCodeGeek opened this issue 3 years ago • 2 comments

I do maximize, minimize, close events through custom controls, and trigger the response through page.update (), but it always feels like a delay of about 0.5 seconds after clicking, not as quickly as the native maximize, minimize, and close. This is my control click event function.

# For example: this is a minimized custom control binding event
Container(content=IconButton(icons.REMOVE_CIRCLE_OUTLINE, on_click=set_window_minimized), alignment=alignment.center)
# This is event logic.
def set_window_minimized(e):
    if page.window_minimized is False:
        page.window_minimized = True
    page.update()

I hope to hear from you. My computer environment is Windows 10 Professional 21H2. @FeodorFitsner

FebCodeGeek avatar Sep 20 '22 07:09 FebCodeGeek

Flet is server driven. the delay may be from that latency generally speaking though my latency is usually 0.1 sec. 0.5 seems like a lot

hololeo avatar Sep 20 '22 13:09 hololeo

Flet is server driven. the delay may be from that latency generally speaking though my latency is usually 0.1 sec. 0.5 seems like a lot

Thank you for your reply. The problem is that it doesn't feel very smooth. I am currently studying how to achieve the built-in effect of the system, but I still need some time to study and solve it while learning Flet development. I hope you have a good plan, you can share.

FebCodeGeek avatar Sep 21 '22 08:09 FebCodeGeek

For me single page.window_minimized=True haven't work at all (Windows 10) But this code fixed it (Maybe some better solutions exist)

def minimizeWindow(e):
    controls = page.controls
    page.controls = []
    page.window_minimized = True
    page.update()
    page.controls = controls
    page.update()

dodiko1d avatar May 08 '23 10:05 dodiko1d

@dodiko1d have a look at the code below:

import flet as ft

def main(page: ft.Page):
    def minimizeWindow(e):
        page.window_minimized = True
        page.update()

    page.add(ft.ElevatedButton("Minimize This Window", on_click=minimizeWindow))

ft.app(target=main)

After setting the property to True, simply call the update and that's it. :)

ndonkoHenri avatar May 08 '23 16:05 ndonkoHenri

@dodiko1d have a look at the code below:

import flet as ft

def main(page: ft.Page):
    def minimizeWindow(e):
        page.window_minimized = True
        page.update()

    page.add(ft.ElevatedButton("Minimize This Window", on_click=minimizeWindow))

ft.app(target=main)

After setting the property to True, simply call the update and that's it. :)

Yeah, already tried, on my PC works worse, missing 25-40% clicks. Maybe something wrong with layout, will try to check next time.

dodiko1d avatar May 08 '23 23:05 dodiko1d

i tried it many times, and i found that if i put the button(connected to min/max event) into a WindowDragArea(as a property), it would have a long delay, but the buttons in normal containers dont

tcbuger avatar Aug 06 '23 18:08 tcbuger

Please guys, move to the latest flet version, retry, and report if or not these issues are still present.

ndonkoHenri avatar Mar 03 '24 17:03 ndonkoHenri