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

window methods do not work in 'loaded' event #528

Closed
bvukotic opened this issue May 25, 2020 · 2 comments
Closed

window methods do not work in 'loaded' event #528

bvukotic opened this issue May 25, 2020 · 2 comments

Comments

@bvukotic
Copy link

bvukotic commented May 25, 2020

Specification

  • pywebview version: 3.2
  • platform / version: Windows 10

Description

My code is:
def on_loaded():
     print("loaded....")
     print(webview.windows[0].get_current_url())

window = webview.create_window('MyApp', "http://127.0.0.1:8000/")
window.loaded += on_loaded
webview.start()

Problem is in
webview.windows[0].get_current_url()
it does not execute. It does not raise exception, it is just stuck there and nothing happens, method 'on_loaded' does not continue. Actually this also happens when I try to call:

webview.windows[0].evaluate_js('... some my javascript....')

I tried to use 'window' instead of webview.windows[0] but result is the same

@r0x0r
Copy link
Owner

r0x0r commented May 25, 2020

There were at least two issues.
a) callbacks were executed before the loaded event was set
b) callbacks were executed on the same thread, which resulted in hanging at least on macOS.

I have opened a PR. There might be side-effects of the logic change, so testing on different platforms and with different events is much appreciated.

@bvukotic
Copy link
Author

I tried it on windows 10, didn't have any problems!

Great job!

@r0x0r r0x0r closed this as completed May 31, 2020
@r0x0r r0x0r mentioned this issue Jun 27, 2020
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

2 participants