Can't open a new window from the JS API
See original GitHub issueSpecification
- Platform: winforms
- Version: 2.0.3
Description
My code looks a bit like this:
import os
import threading
import webview
class FirstWindowApi:
def on_button(self):
webview.destroy_window()
t = threading.Thread(target=create_second_window)
t.start()
class SecondWindowApi:
pass
def create_second_window():
second_window = webview.create_window("Window 2", os.path.abspath("web\\window2.html"), js_api=SecondWindowApi)
first_window = webview.create_window("Window 1", os.path.abspath("web\\window1.html"), js_api=FirstWindowApi)
However, when I click the button, it crashes with this exception:
Exception in thread Thread-3:
Traceback (most recent call last):
File "C:\Program Files\Python36\lib\threading.py", line 916, in _bootstrap_inner
self.run()
File "C:\Program Files\Python36\lib\threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "ui_pywebview.py", line 23, in create_second_window
second_window = webview.create_window("Window 2", os.path.abspath("web\\window2.html"), js_api=SecondWindowApi)
File "C:\Program Files\Python36\lib\site-packages\webview\__init__.py", line 183, in create_window
background_color, debug, js_api, text_select, _webview_ready)
File "C:\Program Files\Python36\lib\site-packages\webview\winforms.py", line 252, in create_window
BrowserView.instances['master'].Invoke(Func[Type](create))
KeyError: 'master'
Issue Analytics
- State:
- Created 5 years ago
- Comments:22 (10 by maintainers)
Top Results From Across the Web
Can't Open New Window with Javascript
I am trying to make a button that will popup a new window using a javascript button pressed by the user.
Read more >Window.open() - Web APIs | MDN
The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a...
Read more >Can't open more than 20 or so tabs with JS map
69 64-bit), if I open more than 20 or so browser tabs with an ArcGIS JS map, the browser tabs all crash. For...
Read more >JavaScript Window open method
It is a pre-defined window method of JavaScript used to open the new tab or window in the browser. This will depend on...
Read more >How to enable JavaScript in Windows
Many Internet Web sites contain JavaScript, a scripting programming language that ... When the "Internet Options" window opens, select the Security tab.
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
@TheInitializer as your case could be solved by switching the order of destroy_window and create_window, I see no reason in keeping application loop alive. Besides how would you terminate the application loop if a keep-alive feature would be implemented?
The threading model should be probably be documented in README.
QT had the same problem as Windows with restarting application loop. All the platforms should be fixed by now.