Comments (15)
Yes, it is definitely doable. Thanks for the suggestion.
I will implement it sometime in the future. Help is more than welcome.
from pywebview.
from pywebview.
Could you make this a callback of some sort? Or some other way to plug in application logic?
from pywebview.
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).
from pywebview.
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.
from pywebview.
FYI, I wrote a wrapper that has an instance method .onclose()
meant to be used as a decorator.
from pywebview.
I have started implementing a confirmation dialog here https://github.com/r0x0r/pywebview/tree/confirmation-dialog
from pywebview.
Great news! just started to use pywebview and thought it would be great to have a confirmation dialog. And here it is, being implemented :)
from pywebview.
Simple OK/Cancel confirmation dialogs are implemented on Windows and OSX. Linux is on the way.
from pywebview.
All platforms support now OK/Cancel confirmation dialog. The confirmation-dialog branch is merged with master.
from pywebview.
Why is this issue still open?
from pywebview.
A three way confirmation dialog (eg. Save, don't save, cancel) is still missing.
from pywebview.
Let's close this one and reopen if there is a concrete need for a three-way dialog
from pywebview.
So, at present, is there a way or workaround to have something like a save confirmation on close?
from pywebview.
You can set window.confirm_close
to True if document needs saving. You cannot set a custom dialog text this way though.
from pywebview.
Related Issues (20)
- Whether to support webgal HOT 4
- how to build android apk HOT 7
- webview tag in pywebview HOT 6
- Support transparency with blurred background. HOT 1
- Drag Area cannot be initialized by a script after page loads. HOT 3
- RangeError: Maximum call stack size exceeded. HOT 7
- Frameless window can not be minimized by clicking its taskbar button HOT 4
- Use window inside of tkinter HOT 4
- iframe cannot call Python HOT 1
- Nuitka support HOT 7
- [WIN] Folder Dialog - New folder is renamed with a delay.
- [Maybe bug] The todos app crashed immediately after I run "buildozer -v android debug deploy run" HOT 13
- google account logout after close the pywebview window HOT 4
- any way to edit the response headers (or somehow disable X-Frame-Options)? HOT 7
- How do I unround the corners of a borderless window?
- [QUESTION] Can pywebview be embedded anywhere? HOT 2
- How can we lift the CORS restrictions in pywebview? HOT 3
- javascript print() not working with pywebview HOT 1
- There's a problem here HOT 2
- Modernize folderdialog? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pywebview.