Skip to main content

Reloads pyside widget when changes are made to module file of the widget.

Project description

PySide Widget Reloader

pyside-widget-reloader is a Python development utility that automatically reload PySide widgets whenever their module file is modified. This can be incredibly useful during the development of graphical user interfaces (GUIs) with PySide, as it eliminates the need for manual reloading of widgets or restarting the application when making changes to the widget files.

🚀 Features

  • Hot reload PySide widgets without restarting your application.
  • Recursive module watching detect changes in a widget’s module and its submodules.

📦 Installation

pip install pyside-widget-reloader

🧩 Usage

Basic Example

from pwreloader import start_reloaders, ReloaderWindow
from myproject.widgets import MyWidget

start_reloaders(
  [ReloaderWindow(MyWidget, 1000)]
)

start_reloaders()

Starts all reloaders. Call this with a list of ReloaderWindows.

ReloaderWindow(WidgetClass, 1000)

This manages reloading of your widget. Pass the widget class (not an instance) that you want to reload and interval in milliseconds.

⚙️ How It Works

The reloader isolates each widget in its own child process, each running its own QApplication instance. This ensures clean reloading without interfering with the main development environment.

🔄 File‑Change Detection

  • At a user‑specified interval (in milliseconds), the system scans the source file of the widget’s module.
  • It computes a hash of the source (optionally using a minified version to ignore changes that don't affect actual behavior, such as whitespace, comments, or variable name changes).
  • If the hash changes, the module is marked for reload.
  • Optionally, a ruff check can be performed; the reload proceeds only if the check passes.

🧭 Module Reload Logic

  • The system can check only the current module, or current module + submodules, depending on settings.
  • check_sub_modules=True: submodules are scanned for changes when scanning the main module, but only the main module is reloaded.
  • reload_sub_modules=True: both changed submodules and the main module are reloaded.
  • Parent modules of the widget's module also be reloaded.

🪄 Widget Reconstruction

Once the required modules are reloaded:

  1. The old widget instance is removed from the window.
  2. A new instance of the widget class is created.
  3. The new widget is inserted into the window, replacing the previous one.

This provides a near‑instant feedback loop for UI development across isolated processes.

🛣️ Roadmap

Compatibility

  • Support latest Python versions.
  • Support latest PySide versions.
  • Add PyQt compatibility.
  • Ensure dependencies (e.g., ruff, python‑minifier) are compatible across supported environments.
  • Add automated CI (e.g., GitHub Actions) to test matrix of Python × PySide × PyQt.

File & Module Scanning System

  • Add ability to scan specific files for reload events.
  • Allow users to include/exclude files or directories from scanning.
  • Provide fine‑grained rules linking file changes to specific module reloads.
  • Implement a mapping system: file → module(s) to reload.

🤝 Contributing

Contributions are welcome! Feel free to open issues, submit PRs, or discuss ideas.

📄 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

pyside_widget_reloader-0.0.2.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

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

pyside_widget_reloader-0.0.2-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file pyside_widget_reloader-0.0.2.tar.gz.

File metadata

  • Download URL: pyside_widget_reloader-0.0.2.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyside_widget_reloader-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c119551b6e10b2f716a1b2043c9dce9b580aed3aa8a65c211f3886872e0507ab
MD5 e7d8cb9278dbdacc189b3a619843e53a
BLAKE2b-256 b1111fa755421523483fdd30db8637641c1869004eed8804cfb4bbb1258fa7e0

See more details on using hashes here.

File details

Details for the file pyside_widget_reloader-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pyside_widget_reloader-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pyside_widget_reloader-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63883bf88d9e803ae6a52b70b807b6adb3129d4ba642c72902706a9ee7453175
MD5 ee1bd70adfc0bd981a607754f57be3c9
BLAKE2b-256 20195f04ba5972ed4e8b98f6fd3944c7648ecb94aad40304ee3f9f9f6a8c6f87

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