Replies: 1 comment 1 reply
-
You can leverage JS API to communicate between windows. This way you setup JS API for each window and facilitate interwindow communication in Python. Here is a toy example import webview
window1 = None
window2 = None
class Api1:
def sayHelloTo(self, name):
if window2:
window2.evaluate_js(f"document.write('Hello from {name}')")
class Api2:
def sayHelloTo(self, name):
if window1:
window1.evaluate_js(f"document.write('Hello from {name}')")
if __name__ == '__main__':
window1 = webview.create_window('Window #1', html='<button onclick="pywebview.api.sayHelloTo(\'window1\')">Say hello</button>', js_api=Api1())
window2 = webview.create_window('Window #2', html='<button onclick="pywebview.api.sayHelloTo(\'window2\')">Say hello</button>', js_api=Api2())
webview.start() Local storage should work as long you use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I wrote a program in Python 3.10 with pyWebView and bottle server as the default server on OSX. It all works fine.
Now I would like to create a communication between 2 of the windows my application creates. I tried many js framework using localstorage, events... but none of them received the message.
Is there a way for one window to trigger an event into another one ?
Thanks,
Christian
Beta Was this translation helpful? Give feedback.
All reactions