Turn click CLI's into QT applications
Project description
clickqt
clickqt generates Qt GUIs from click commands. Your click CLI remains the single source of truth, your users get the benefit from a GUI.
Feature List
- Build a GUI automatically from
clickCLIs - Launch GUIs for already installed CLIs (or from a Python file) via
clickqtfy. - Ship a GUI for your Python package with three lines of code
- Map common
clicktypes to Qt widgets, includingbool,int,float,str,Choice,DateTime,Path,File, tuple,nargs, andmultiple. - Support for hierarchically nested
click.Groups - Carry over defaults, required flags, callbacks, and envvar-based initialization.
- Execute your command from the GUI and stream stdout/stderr to an in-app terminal panel.
- Export the current GUI state as a shell command and import command lines from the clipboard.
- Support option grouping headers from
click-option-group.
Installation instructions
clickqt requires Python >=3.10.
Install from PyPI:
python -m pip install clickqt
Install from conda-forge:
conda install -c conda-forge clickqt
Install for local development:
python -m pip install --editable .[tests]
pre-commit install
Usage for end users (via clickqtfy)
Generate a GUI from an installed entry point:
clickqtfy ENTRYPOINT
Generate a GUI from a Python file and a click command object name:
clickqtfy path/to/module.py COMMAND_FUNCTION
In the generated GUI:
Runexecutes the current command.Stoprequests interruption of a running command.Copy-To-Clipboardexports the current command line.Import-From-Clipboardparses a command line and updates widgets.
Usage for library maintainers
Expose a GUI to your users via the qtgui_from_click function:
import click
from clickqt import qtgui_from_click
@click.command()
@click.option("--count", default=1, type=int)
@click.argument("name")
def greet(count: int, name: str) -> None:
for _ in range(count):
click.echo(f"Hello {name}")
greet_gui = qtgui_from_click(
greet,
application_name="Greeter",
invocation_command="greet",
)
Publish CLI and GUI entry points in pyproject.toml:
[project.scripts]
greet = "yourpkg.cli:greet"
[project.gui-scripts]
greet_gui = "yourpkg.cli:greet_gui"
For custom click.ParamType, provide a widget/getter/setter mapping:
from PySide6.QtWidgets import QLineEdit
custom_mapping = {
MyParamType: (
QLineEdit,
lambda w: w.widget.text(),
lambda w, v: w.widget.setText(str(v)),
)
}
gui = qtgui_from_click(cmd, custom_mapping=custom_mapping)
Constraints
- Unknown custom
click.ParamTypefalls back to a text field unless you providecustom_mapping. click-option-groupis displayed visually, but group relationship rules are not enforced byclickqt.- Parameters with
hidden=Trueare currently still rendered in the GUI. clickqtexecutes command callbacks directly; advanced customclick.Command/click.Contextbehavior may differ from CLI invocation.- Multi-value envvar handling can differ from Click's type-specific envvar splitting behavior.
Licensing
MIT License. See LICENSE.md.
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
File details
Details for the file clickqt-1.0.0.tar.gz.
File metadata
- Download URL: clickqt-1.0.0.tar.gz
- Upload date:
- Size: 98.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ec4d6a10e8ce1a3200f63b464c0c579c1ed59cfb88a19cc2ade3aecd7a53b47
|
|
| MD5 |
2070392627bc56a0d9511993c4d6a54b
|
|
| BLAKE2b-256 |
5fb2d43be606aa9ec22c86c7747f1339c89637d3917dfd684432c0d78ac52fd7
|
Provenance
The following attestation bundles were made for clickqt-1.0.0.tar.gz:
Publisher:
pypi.yml on ssciwr/clickqt
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clickqt-1.0.0.tar.gz -
Subject digest:
5ec4d6a10e8ce1a3200f63b464c0c579c1ed59cfb88a19cc2ade3aecd7a53b47 - Sigstore transparency entry: 997332241
- Sigstore integration time:
-
Permalink:
ssciwr/clickqt@a1e3d36a546b0b0fe966ce65caed1196d39e52dd -
Branch / Tag:
refs/heads/main - Owner: https://github.com/ssciwr
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi.yml@a1e3d36a546b0b0fe966ce65caed1196d39e52dd -
Trigger Event:
workflow_dispatch
-
Statement type: