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

Confirm on close #31

Closed
michel-cf opened this issue Apr 28, 2016 · 15 comments
Closed

Confirm on close #31

michel-cf opened this issue Apr 28, 2016 · 15 comments

Comments

@michel-cf
Copy link

I'd like use this in my project, but one of my functional requirements is a confirm dialog on close.

Is this something that can be easily added?

@r0x0r
Copy link
Owner

r0x0r commented Apr 30, 2016

Yes, it is definitely doable. Thanks for the suggestion.
I will implement it sometime in the future. Help is more than welcome.

@r0x0r
Copy link
Owner

r0x0r commented Jun 11, 2016

Bounty

@AstraLuma
Copy link
Contributor

Could you make this a callback of some sort? Or some other way to plug in application logic?

@r0x0r
Copy link
Owner

r0x0r commented Oct 31, 2016

How would you envision a callback?
I can think of two basic confirmation types: Are you sure you want to exit (Yes, No) and You have unsaved changes (Save, Don't Save, Cancel). The first one certainly does not need a callback, but the second one, could use one for the Save functionality. Localization would be nice too (currently all the strings are hardcoded in English).

@AstraLuma
Copy link
Contributor

Well, there's also the problem of how to display such a dialog. If the application has other dialogs/prompts, it should be displayed in the same style--which is probably HTML. (Although Tkinter does have some APIs for native system dialogs.)

There's also other kinds of "do you want to exit" prompts: "Do you want to disconnect?", "Can't exit now; please wait for outstanding jobs to finish.", other variations of "unsaved data".

The simplest thing to do would probably be to add a keyword argument exitcallback. Returns a bool: True to cancel, False (or None) to exit. It also wouldn't be unreasonable to add a module-level function to set it.

@AstraLuma
Copy link
Contributor

FYI, I wrote a wrapper that has an instance method .onclose() meant to be used as a decorator.

@r0x0r
Copy link
Owner

r0x0r commented Feb 20, 2017

I have started implementing a confirmation dialog here https://github.com/r0x0r/pywebview/tree/confirmation-dialog

@simplynail
Copy link

Great news! just started to use pywebview and thought it would be great to have a confirmation dialog. And here it is, being implemented :)

@r0x0r
Copy link
Owner

r0x0r commented Mar 3, 2017

Simple OK/Cancel confirmation dialogs are implemented on Windows and OSX. Linux is on the way.

@r0x0r
Copy link
Owner

r0x0r commented Mar 3, 2017

All platforms support now OK/Cancel confirmation dialog. The confirmation-dialog branch is merged with master.

@shivaprsd
Copy link
Collaborator

Why is this issue still open?

@r0x0r
Copy link
Owner

r0x0r commented Apr 17, 2017

A three way confirmation dialog (eg. Save, don't save, cancel) is still missing.

@r0x0r
Copy link
Owner

r0x0r commented Sep 18, 2017

Let's close this one and reopen if there is a concrete need for a three-way dialog

@r0x0r r0x0r closed this as completed Sep 18, 2017
@NiceneNerd
Copy link

So, at present, is there a way or workaround to have something like a save confirmation on close?

@r0x0r
Copy link
Owner

r0x0r commented Jun 18, 2020

You can set window.confirm_close to True if document needs saving. You cannot set a custom dialog text this way though.

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

No branches or pull requests

6 participants