New API
See original GitHub issueNOTE: 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:
- Created 5 years ago
- Reactions:2
- Comments:15 (9 by maintainers)
Top GitHub Comments
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.
I have made some progress on this, namely
webview.windows
propertywebview.config
is gone. GUI selection is done via the gui parameter ofwebview.start
webview.start
. The function has the following signaturestart(func=None, args=None, localization={}, multiprocessing=False, gui=None, debug=False)
This has been pushed to the
pywebview-3
branchTODO
As always help and comments are welcomed