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.0rc7.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.0rc7-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webview_proc-0.1.0rc7.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.0rc7.tar.gz
Algorithm Hash digest
SHA256 bf136f1b5da9c26d586e46fc06a76fa41af65c8f63a51993bc88fed8a7337f55
MD5 61e32034e88f66e879bb28712df4e00c
BLAKE2b-256 68fd96b50fb04e9c4ab4bf5863baf955ec89e797bc726c655b48d15170c805de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webview_proc-0.1.0rc7-py3-none-any.whl
Algorithm Hash digest
SHA256 05ee7428f7074dc0cbf2b09697cfc35a34b55c95c01d8f28a3fbfe5e8778aa4b
MD5 d33052d1d1192f66f6640adb6b29afbf
BLAKE2b-256 3ba3997510528f30dd27e864649c29227fbaeeffc179be0bd4ab1c8f19f78c21

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