r0x0r / pywebview

Build GUI for your Python program with JavaScript, HTML, and CSS
https://pywebview.flowrl.com
BSD 3-Clause "New" or "Revised" License
4.62k stars 537 forks source link

Event for window being ready #549

Closed danpalmer closed 4 years ago

danpalmer commented 4 years ago

Specification

Description

The current lifecycle of a window is roughly...

  1. Create window
  2. Event loop starts
  3. Simultaneously:
    • Start callback function is called
    • Window backing view/environment is created
  4. URL is loaded
  5. First event, loaded is fired.

I'm attempting to inject some custom configuration (cookies, see #548) directly into the WKWebView backing a window, but there isn't a convenient hook to do this when the webview has been instantiated. My current solution is to wait for 1 second in the init function.

I can work around this, but it seems like it would be nice to have another event for this more advanced use-case.

Practicalities

No and No. This isn't blocking me so I'm afraid I can't dedicate time to solving it.

r0x0r commented 4 years ago

Does window.shown work for you?

danpalmer commented 4 years ago

It doesn't appear to. The window appears to be shown as soon as it's created.

r0x0r commented 4 years ago

shown is implemented as a mixed bag. In some cases it is fired in the constructor after everything else, in other cases on a dedicated event. The best course would be to fire shown after a webview is ready. Would this help your use case?

github-actions[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 4 years ago

The message to post on the issue when closing it. If none provided, will not comment when closing an issue.