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

Update app-exit-confirm-dialog.py #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions python/controls/page/app-exit-confirm-dialog.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
import flet
from flet import AlertDialog, ElevatedButton, OutlinedButton, Page, Text


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

def window_event(e):
if e.data == "close":
page.dialog = confirm_dialog
# Use the updated method to append the dialog to the overlay
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for this comment too.

page.overlay.append(confirm_dialog)
confirm_dialog.open = True
page.update()

page.window_prevent_close = True
page.on_window_event = window_event
page.window.prevent_close = True
page.window.on_event = window_event

def yes_click(e):
page.window_destroy()
# Use the updated method to destroy the window
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add comments in this case.

page.window.destroy()

def no_click(e):
confirm_dialog.open = False
Expand All @@ -34,5 +35,5 @@ def no_click(e):

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


flet.app(target=main)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why two lines to run the app?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!, copy paste typo! eek!

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