question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NOTE: the original description below no longer reflects current design. Refer to the docs instead.

This is going to be the first ever breaking change, so let’s make this 3.0 once it is done. This matter was discussed earlier. As this is quite a big change, I would like to get it implemented before other features to keep conflicts low.

The API would introduce a new function webview.start(callback=None, parameters=(), multiprocessing=False) that would start the UI loop and block program execution. The bare minimum hello world example would be then

import webview
window = webview.create_window("Test", "http://example.org")
webview.start()

Multiple window example would be

import webview
window1 = webview.create_window("Test 1", "http://example.org")
window2 = webview.create_window("Test 2", "http://example.org")
webview.start()

All the webview functions related to the created window will be move to the Window object returned by create_window. For example Loading HTML would be

import webview

def load_html(window):
  window.load_html("Hello world!")

window1 = webview.create_window("Test 1")
webview.start(load_html, window)

Moreover, I propose a new function signature of create_window, so that all window options would be in a separate object and localization moved out of create_window. So that

webview.create_window(title, url=None, js_api=None, options={})

webview.localization = { ... } # default localization object

Specifying window option would be like this

webview.create_window("Test", options={'resizable': False, 'fullscreen': True})

I am not sure what to do with the confirm_quit switch. Semantically it should be a global, not a window specific parameter, but I am not comfortable to moving it to webview.config.

It would not hurt to introduce webview.windows property that would contain all the opened windows.

@shivaprsdv Would you be able to give this a hand at some point?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
r0x0rcommented, May 18, 2019

Events in Cocoa are fixed as well. Tests in Travis are failing as usual, but I get no errors locally. I left multiprocessing support out of this release, as it turned out to be more complex than I thought. Other than that, refactoring is complete. I am closing this issue.

1reaction
r0x0rcommented, Jun 18, 2019

I have made some progress on this, namely

  • init has the new API
  • Introduced Window and webview.windows property
  • Cocoa implementation is done apart from bugs here and there
  • Examples and tests are largely refactored to conform to the new API
  • Steps are made for a new event systems. I have introduced two events: shown (window is created) and loaded (DOM is ready).
  • webview.config is gone. GUI selection is done via the gui parameter of webview.start
  • win32 implementation is gone
  • localization and debug are now parameters to webview.start. The function has the following signature start(func=None, args=None, localization={}, multiprocessing=False, gui=None, debug=False)

This has been pushed to the pywebview-3 branch

TODO

  • CEF and Winforms implementations.
  • QT implementation
  • GTK implementation
  • On Cocoa shown event should launch on window load and not application load. I did a cursory research and it seems it should be implemented via a NSViewController. @shivaprsdv Could you take a look at this?
  • Observers for news events
  • Documentation update
  • _api_call should be split into two different methods for shown and loaded events

As always help and comments are welcomed

Read more comments on GitHub >

github_iconTop Results From Across the Web

News API – Search News and Blog Articles on the Web
Get JSON search results for global news articles in real-time with our free News API. ... Or leave blank to get the up-to-the-minute...
Read more >
New API - Wikipedia
New API (also referred to as NAPI) is an interface to use interrupt mitigation techniques for networking devices in the Linux kernel.
Read more >
NewsData.io: Free News API to Search & Collect News and ...
Get news API to search, collect and analyse any News and Blog articles from the Web. Get historical and real-time news API access...
Read more >
Top 10 Best News APIs (for Developers in 2022) [60+ Reviewed]
The NewsAPI is a simple and easy to use REST API that returns JSON metadata for headlines currently published from over 30,000 news...
Read more >
9 Best Global News APIs for Your Next Product - Geekflare
9 Best Global News APIs for Your Next Product · Mediastack · Webhose · News API · NewscatcherAPI · New York Times ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found