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.0rc3.tar.gz (9.5 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.0rc3-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: webview_proc-0.1.0rc3.tar.gz
  • Upload date:
  • Size: 9.5 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.0rc3.tar.gz
Algorithm Hash digest
SHA256 4ef293197a0878bc8edf9f8855197d64fd87684e037b65ec5046af350f584af9
MD5 2a81bee086a82c0abab7db0f48c42e7d
BLAKE2b-256 2bc7e1d749cd1df8d334405ff9bd114e83a5e84c890839a2bd843f1719be1516

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for webview_proc-0.1.0rc3-py3-none-any.whl
Algorithm Hash digest
SHA256 5cd4caebfaa1f9deff009830096aa9bf6be7e04b80084525f91b97c81d4b0d65
MD5 2dcb9dc2ecf0a604bf8c13ca837731f5
BLAKE2b-256 8027ce517d6f3147ceec5bac75a79db516864c356535673aca561e183ac8c419

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