How do destroy window by calling a Python function via the JS API?
See original GitHub issueSpecification
- pywebview version: 3.3.5
- platform / version: Windows 10
Description
import webview
html = """
<!DOCTYPE html>
<html>
<head lang="en">
</head>
<body>
<h1>JS API Example</h1>
<button onclick="close()">close</button>
<script>
function close() {
pywebview.api.close();
}
</script>
</body>
</html>
"""
class Api:
def close(self):
window.destroy()
window = webview.create_window('test',
html=html,
easy_drag=False,
js_api=Api,
frameless=True)
webview.start()
Practicalities
-
YES I am willing to work on this issue myself.
-
NO I am prepared to support this issue financially.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
how to return a "close window" command from a GET call?
You could change your Python lambda script to return HTML and execute the window.close() javascript function.
Read more >Window.close() - Web APIs - MDN Web Docs - Mozilla
The Window.close() method closes the current window, or the window on which it was called.
Read more >Window close() Method - W3Schools
Use open() to open a window and close() to close the window: let myWindow; function openWin() { myWindow = window.open("", "myWindow", "width=200, ...
Read more >How to close window using JavaScript which is opened by the ...
Step 2: Close this open window using the close() method: The window.close() method closes the window on which it is called. The window...
Read more >A First Look at PyScript: Python in the Web Browser
You'll leverage browser APIs and JavaScript libraries to build rich, ... you can call Pyodide's loadPackage() function using its Python ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try
_close()
asclose()
is already definedclose is a global js function. this has nothing to do with pywebview.