6.0 is here

6.0 is here
I am excited to announce the release of pywebview 6. The new version introduces powerful state management, network event handling, and significant improvements to Android support. For a complete changelog, see here.
If you are not familiar with pywebview, it's a lightweight Python framework for building modern desktop applications with web technologies. Unlike heavyweight alternatives, pywebview leverages your system's native webview, resulting in smaller binaries and better performance. Write your UI once in HTML, CSS, and JavaScript, then deploy across Windows, macOS, Linux, and Android with the full power of Python at your fingertips. pywebview can be installed with
pip install pywebview
Shared State Management
One of the most exciting features in version 6 is the new shared state management via the window.state
object. This revolutionary feature automatically synchronizes state between Javascript and Python, eliminating the need for manual data synchronization.
# In Python
window.state.user_name = "Test"
// In Javascript - automatically updated!
console.log(window.pywebview.state.user_name); // "Test"
This bidirectional synchronization makes building complex applications much simpler, as you no longer need to manually pass data between Python and Javascript. Currenlty state syncronization is limited to top-level properties. If you want to synchronize nested objects, you need to reassign the entire object. For example:
# In Python
window.state.user_settings = {"theme": "dark", "notifications": True}
// In Javascript - automatically updated!
console.log(window.pywebview.state.user_settings); // {"theme": "dark", "notifications": True}
window.pywebview.state.user_settings = {"theme": "light", "notifications": False} // Updates Python side too
New events
pywebview 6 introduces powerful network monitoring capabilities with the new request_sent
and response_received
events. These events are fired whenever HTTP requests are made, giving you full visibility into your application's network activity. Request headers can be modified before sending, and you can inspect responses as they arrive. Response header modification is not supported.
def on_request_sent(request):
print(f"Sending request to: {request['url']}")
# Modify request headers before sending
request['headers']['Authorization'] = f"Bearer {get_auth_token()}"
def on_response_received(response):
print(f"Received response: {response['status_code']}")
window.events.request_sent += on_request_sent
window.events.response_received += on_response_received
Another new event is initialized
, which is fired when the GUI library or webview renderer is chosen, before the window is created. This allows you to customize behavior based on the selected renderer or abort execution altogether by returning False
from the event handler.
def on_initialized(renderer):
print(f"Initialized with renderer: {renderer}")
window.events.initialized += on_initialized
Enhanced Android Support
Android support receives a major upgrade with a new Kivyless implementation that significantly improves startup time and reduces package size. Additionally, Android apps now support fullscreen mode, bringing mobile experience closer to native apps.
Furthermore Android now has a new dedicated test suite found in tests/android
.
Window-Specific Menus
You can now create custom menus for individual windows, giving you more control over the user interface (not supported on GTK with Unity)
menu = webview.menu.Menu([
webview.menu.MenuAction('File', [
webview.menu.MenuAction('New', new_file),
webview.menu.MenuSeparator(),
webview.menu.MenuAction('Exit', exit_app)
])
])
window = webview.create_window('My App', 'index.html', menu=menu)
Modern API Improvements
Version 6 includes several breaking changes that modernize the API and removes deprecated features:
- File dialog constants are now part of the
webview.FileDialog
enum (SAVE
,LOAD
,FOLDER
) webview.DRAG_REGION_SELECTOR
moved towebview.settings['webview.DRAG_REGION_SELECTOR']
- Deprecated DOM functions are removed in favor of the modern
window.dom
API
Platform-Specific Enhancements
- Windows: Dark mode support with automatic theme detection
- macOS: Option to hide default menus and better Javascript prompt handling
- All platforms: Improved screen coordinate handling and better SSL support
Learn more
Ready to explore pywebview 6? Check out the usage guide, API reference and examples to get started with the new features.
Support the project
pywebview continues to be primarily a one-person project, updated when time allows. Your contributions make a real difference! The best way to help is by submitting pull requests - bug fixes are always welcome, and for new features, please create an issue to discuss first. Check out the contributing guide to get started.
If pywebview has been useful for your projects and you'd like to see continued development, consider sponsoring the project. Companies can become sponsors to gain exposure and connect with the Python developer community.