DESCRIPTION: pywebview 5. The new version introduces three major features: Android support, DOM manipulation, and application settings. For a full changelog, see here.
If you are not familiar with pywebview, it is a Python library that lets you build a GUI for your Python program using HTML, CSS, and Javascript. Available for Windows, macOS, Linux, and Android. pywebview can be installed with
pip install pywebview
Android
You can now run your pywebview on Android devices. Mobile experience brings its own limitations though. There is no window manipulation, multi-window, or file dialog support. Otherwise, it works the same as on other platforms. Head over to Freezing for details on how to package your app for Android.
DOM
With DOM support, you can perform jQuery-like DOM manipulation, traversal, and event handling straight from Python. You can access and modify element's attributes, style, and classes as well. A new Element object represents a DOM node in Python. It is returned by window.dom.get_element, window.dom.get_elements, and window.dom.create_element. Body, document, and window are conveniently exposed as window.dom.body, window.dom.document, and window.dom.body respectively. The new Javascript serializer allows you to serialize more Javascript object types and handles circular dependencies.
See events, manipulation, events for complete examples.
A much-requested feature is full file path support for drag and drop operations. pywebview enhances DropEvent by introducing event['dataTransfer']['files'][0]['pywebviewFullPath'] that has the full absolute path of a dropped file(s). The full path is available only on Python's side.
Application settings
pywebview is rather opinionated on how the default experience should be. Over the years, I have received numerous feature requests asking to change the default behavior, which is now possible with application settings. The new version introduces webview.settings dictionary with the following options.
webview.settings = {
'ALLOW_DOWNLOADS': False, # Allow file downloads
'ALLOW_FILE_URLS': True, # Allow access to file:// urls
'OPEN_EXTERNAL_LINKS_IN_BROWSER': True, # Open target=_blank links in an external browser
'OPEN_DEVTOOLS_IN_DEBUG': True, # Automatically open devtools when `start(debug=True)`.
}
Application settings must be set before invoking webview.start() to have an effect.
{'label-name': 'python-libraries', 'label-description': 'Topics related to Python libraries and their functionalities.', 'gh-repo': 'web-development', 'confidence': 53.87}
pywebview
DESCRIPTION: pywebview 5. The new version introduces three major features: Android support, DOM manipulation, and application settings. For a full changelog, see here.
If you are not familiar with pywebview, it is a Python library that lets you build a GUI for your Python program using HTML, CSS, and Javascript. Available for Windows, macOS, Linux, and Android. pywebview can be installed with
Android
You can now run your pywebview on Android devices. Mobile experience brings its own limitations though. There is no window manipulation, multi-window, or file dialog support. Otherwise, it works the same as on other platforms. Head over to Freezing for details on how to package your app for Android.
DOM
With DOM support, you can perform jQuery-like DOM manipulation, traversal, and event handling straight from Python. You can access and modify element's attributes, style, and classes as well. A new Element object represents a DOM node in Python. It is returned by
window.dom.get_element
,window.dom.get_elements
, andwindow.dom.create_element
. Body, document, and window are conveniently exposed aswindow.dom.body
,window.dom.document
, andwindow.dom.body
respectively. The new Javascript serializer allows you to serialize more Javascript object types and handles circular dependencies.Here is a toy example of the new API.
See events, manipulation, events for complete examples.
A much-requested feature is full file path support for drag and drop operations. pywebview enhances DropEvent by introducing
event['dataTransfer']['files'][0]['pywebviewFullPath']
that has the full absolute path of a dropped file(s). The full path is available only on Python's side.Application settings
pywebview is rather opinionated on how the default experience should be. Over the years, I have received numerous feature requests asking to change the default behavior, which is now possible with application settings. The new version introduces
webview.settings
dictionary with the following options.Application settings must be set before invoking
webview.start()
to have an effect.URL: https://pywebview.flowrl.com/blog/pywebview5.html
Suggested labels
{'label-name': 'python-libraries', 'label-description': 'Topics related to Python libraries and their functionalities.', 'gh-repo': 'web-development', 'confidence': 53.87}