Skip to main content

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 pywebview windows in a separate thread for crash isolation.
  • Synchronous WebViewProcess class 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 pywebview GUI 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

webview_proc-0.1.0rc6.tar.gz (9.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

webview_proc-0.1.0rc6-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file webview_proc-0.1.0rc6.tar.gz.

File metadata

  • Download URL: webview_proc-0.1.0rc6.tar.gz
  • Upload date:
  • Size: 9.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for webview_proc-0.1.0rc6.tar.gz
Algorithm Hash digest
SHA256 42aa35a29510b86c43dab0b80a9acd32f97fabd9d106fa6cac51d98f11d3f65a
MD5 cb4ab6aae58fed3670f7498170ffbc09
BLAKE2b-256 30bfec93dd8419c2ad74140b7ec97fb864fb841e4bf39a7e4bfde1e729ba75bf

See more details on using hashes here.

File details

Details for the file webview_proc-0.1.0rc6-py3-none-any.whl.

File metadata

File hashes

Hashes for webview_proc-0.1.0rc6-py3-none-any.whl
Algorithm Hash digest
SHA256 c2c861fe48d9f8137754f06236eb5d9ca30eac96f7a59c3eaac3ccb9d4b3674b
MD5 2aad8dc0191bc6bf8626a91dd8a3f8de
BLAKE2b-256 8cb7739f9919f8580998a32d07a27f9834898ee5a77c4afafe1bbb1c39060f5c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page