A Python package for running pywebview windows in a separate thread, providing a synchronous API for stable and isolated webview management.
Project description
webview-proc
webview-proc is a Python package that simplifies running pywebview windows in a separate thread, enhancing stability and performance for desktop applications by isolating webview operations from the main thread. The WebViewProcess class provides a synchronous API for creating, managing, and communicating with webview windows, supporting operations like opening, closing, resizing, maximizing, toggling fullscreen, setting titles, handling file dialogs, and evaluating JavaScript. Ideal for hybrid applications combining web technologies with native interfaces, webview-proc offers a lightweight and extensible solution for Python developers.
Features
- Run
pywebviewwindows in a separate thread for crash isolation. - Synchronous
WebViewProcessclass for simple, blocking operations. - Comprehensive API for window operations: open, close, resize, maximize, fullscreen, set title, file dialogs, and JavaScript evaluation.
- Thread-safe communication for reliable control.
- Cross-platform support (Windows, macOS, Linux) with flexible
pywebviewGUI backends (e.g., Qt, GTK, Cocoa). - Extensible for other webview engines (e.g., QtWebEngine, CEF).
Installation
pip install webview-proc
Basic Usage
from webview_proc import WebViewProcess
# Create a webview process
webview = WebViewProcess(
url="http://localhost:8000",
title="My App",
width=800,
height=600,
icon_path="path/to/icon.png",
)
# Start the webview in a separate thread
webview.start()
# Perform window operations
webview.set_title("New Title")
webview.resize(1000, 700)
webview.toggle_fullscreen()
# Open a file dialog
files = webview.pick_file(file_types=["pdf", "png"], multiple=True)
# Close the window
webview.close()
# Wait for the thread to terminate
webview.join()
Why webview-proc?
webview-proc addresses the need for stable and isolated webview management in Python applications. By running pywebview windows in a separate thread, it prevents crashes from affecting the main application. The synchronous WebViewProcess class is ideal for scripts and applications requiring simple, blocking operations, and it integrates seamlessly with web servers (e.g., FastAPI). The package handles platform-specific quirks (e.g., main-thread requirements on macOS), making it suitable for desktop and hybrid web apps.
Contributing
Contributions are welcome! Check out our Contributing Guidelines and Issue Tracker to get started.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file webview_proc-0.1.0rc4.tar.gz.
File metadata
- Download URL: webview_proc-0.1.0rc4.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4cc7bb3f83fc901bfcaef866da9d42693519b92f9a2a6b3fe99ce9227f946a17
|
|
| MD5 |
3893bc3e3a514b20ddf919fdaa01b036
|
|
| BLAKE2b-256 |
8000a1e58a0bf54d4708be93de7454976c6c6bae8621c3e54f452548386e39d9
|
File details
Details for the file webview_proc-0.1.0rc4-py3-none-any.whl.
File metadata
- Download URL: webview_proc-0.1.0rc4-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b503442895c4aad61afeda018f4d1291eac88c8f71c429120e122820ad413d6
|
|
| MD5 |
fb1e6ed68942d6c02b057bc5cd4c197f
|
|
| BLAKE2b-256 |
b845d1687f70278c42e235deeddb3415a5cc855142f95b73099b96b7b0fea2ee
|