Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No page.on_window_event on close #1626

Open
rkleivel opened this issue Jul 24, 2023 · 8 comments
Open

No page.on_window_event on close #1626

rkleivel opened this issue Jul 24, 2023 · 8 comments

Comments

@rkleivel
Copy link

Description

I get no window event on window close, Ubuntu 22.04, flet 0.8.2, python 3.10

Code example to reproduce the issue:

# https://flet.dev/docs/controls/page#window_destroy

import flet as ft

def main(page: ft.Page):
    page.title = "MyApp"

    def window_event(e):
        print(e.data)
        if e.data == "close":
            page.dialog = confirm_dialog
            confirm_dialog.open = True
            page.update()

    page.window_prevent_close = True
    page.on_window_event = window_event

    def yes_click(e):
        page.window_destroy()

    def no_click(e):
        confirm_dialog.open = False
        page.update()

    confirm_dialog = ft.AlertDialog(
        modal=True,
        title=ft.Text("Please confirm"),
        content=ft.Text("Do you really want to exit this app?"),
        actions=[
            ft.ElevatedButton("Yes", on_click=yes_click),
            ft.OutlinedButton("No", on_click=no_click),
        ],
        actions_alignment=ft.MainAxisAlignment.END,
    )

    page.add(ft.Text('Try exiting this app by clicking window\'s "Close" button!'))

ft.app(target=main)

Describe the results you received:

No dialog to confirm closing is shown, no print of "close" as expected from print(e.data)

Describe the results you expected:

Would expect e.data = "close" when closing window

Additional information you deem important (e.g. issue happens only occasionally):

Flet version (pip show flet):

Name: flet
Version: 0.8.2
Summary: Flet for Python - easily build interactive multi-platform apps in Python
Home-page: 
Author: Appveyor Systems Inc.
Author-email: hello@flet.dev
License: Apache-2.0
Location: /home/roald/KMM/stillOnWheels/stowImporter/env/lib/python3.10/site-packages
Requires: copier, flet-runtime, packaging, pydantic, qrcode, watchdog, websocket-client, websockets
Required-by: 

Operating system:

Ubuntu 22.04

Additional environment details:

pip freeze
anyio==3.7.1
blake3==0.3.3
certifi==2023.5.7
colorama==0.4.6
copier==8.1.0
decorator==5.1.1
dunamai==1.18.0
exceptiongroup==1.1.2
flet==0.8.2
flet-core==0.8.2
flet-runtime==0.8.2
funcy==2.0
h11==0.14.0
httpcore==0.17.3
httpx==0.24.1
idna==3.4
Jinja2==3.1.2
jinja2-ansible-filters==1.3.2
MarkupSafe==2.1.3
oauthlib==3.2.2
packaging==23.1
pathspec==0.11.1
plumbum==1.8.2
prompt-toolkit==3.0.39
psutil==5.9.5
pydantic==1.10.11
Pygments==2.15.1
pypng==0.20220715.0
PyYAML==6.0
pyyaml-include==1.3.1
qrcode==7.4.2
questionary==1.10.0
repath==0.9.0
six==1.16.0
sniffio==1.3.0
typing_extensions==4.7.1
watchdog==3.0.0
wcwidth==0.2.6
websocket-client==1.6.1
websockets==11.0.3
@ndonkoHenri
Copy link
Collaborator

ndonkoHenri commented Jul 26, 2023

I ran the code, and hat the dialog come up. The "close" was printed in the console and clicking on "Yes" closed the app as expected. All this with flet v0.8.2.

Try moving to the latest version, then try again. If it persists make a screen recording and send please.

@rkleivel
Copy link
Author

rkleivel commented Aug 3, 2023

Thanks @ndonkoHenri for diving into it!
Here is a screen recording of the issue on a fresh Ubuntu 22.04 VirtualBox installation - flet version 0.8.4. As you can see blur and focus is printed out by the extra line print(f"e.data: {e.data}"). But when pressing the upper right X button in the window, it does not print any close as expected, and the window closes right away without displaying the "Please confirm" dialog. Can you spot any wrongdoing from my side here?

UB2204-desk-screen0.mp4

@ndonkoHenri
Copy link
Collaborator

Seems like the Problem is OS-related.

@rkleivel
Copy link
Author

rkleivel commented Aug 4, 2023

OK - could be. I've reproduced the issue on Debian12/Gnome and Debian12/XFCE also.
Which OS are you on @ndonkoHenri ?
I wonder if it has some kind of relation to #1556 - which also seems to be OS-related

@ndonkoHenri
Copy link
Collaborator

I use Win10.

@rkleivel
Copy link
Author

rkleivel commented Aug 8, 2023

I use Win10.

I can confirm it works in Win10 with me also. So probably OS-related(?)

@ndonkoHenri
Copy link
Collaborator

Yup, I think so.

@AI-Elbaz
Copy link

Is there any updates about this issue, the exact same thing happens to me on windows 11,
it captures all events except the close event
I'm using python 3.10.9
flet 0.10.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants