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

[Feature] Message Box function #1379

Open
divadsn opened this issue May 11, 2024 · 5 comments
Open

[Feature] Message Box function #1379

divadsn opened this issue May 11, 2024 · 5 comments

Comments

@divadsn
Copy link

divadsn commented May 11, 2024

Specification

  • pywebview version: 5.1
  • operating system: Windows 10
  • web renderer: edgechromium

Description

I have not seen any method to create a message box in pywebview, only some half-baked solutions using Tk, but they don't integrate very well with the window GUI. There was a method in the PR for #949 but it doesn't seem to be in 5.1 anymore 🤔

JS alert() don't look good on Windows with edgechromium

@r0x0r
Copy link
Owner

r0x0r commented May 12, 2024

it is create_confirmation_dialog

@divadsn
Copy link
Author

divadsn commented May 13, 2024

Yes but that one creates as the name already tells an Yes/No dialog, I am searching for a method to have an alert/message box with an icon (warning/info/error) and an OK button. alert() in JS shows the built-in error which doesn't look good:

image

@r0x0r
Copy link
Owner

r0x0r commented May 13, 2024

There is a custom message box implementation that overwrites window.alert, but it is not enabled for EdgeChromium. I will look into this.

@yllhwa
Copy link
Contributor

yllhwa commented May 14, 2024

If you only plan to run on Windows, simply use win32 api like this.

import webview
import ctypes


def my_alert(title, text, flags=0x00001030):
    ctypes.windll.user32.MessageBoxW(None, text, title, flags)


window = webview.create_window("Hello world", "https://pywebview.flowrl.com/hello")
window.expose(my_alert)
webview.start(debug=True)

# js: pywebview.api.my_alert("Error", "error while loading")

image

@r0x0r
Copy link
Owner

r0x0r commented May 14, 2024

I pushed a fix to master

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