Giter Club home page Giter Club logo

Comments (15)

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

Bounty

from pywebview.

AstraLuma avatar AstraLuma commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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.

AstraLuma avatar AstraLuma commented on May 18, 2024

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.

AstraLuma avatar AstraLuma commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

simplynail avatar simplynail commented on May 18, 2024

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.

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

shivaprsd avatar shivaprsd commented on May 18, 2024

Why is this issue still open?

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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

from pywebview.

NiceneNerd avatar NiceneNerd commented on May 18, 2024

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

from pywebview.

r0x0r avatar r0x0r commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.