vitruvian-tool-kit
Write a tool for the Vitruvian Mac app in
Python. A tool is a folder with a vitruvian-tool.json and a program; the app
starts the program and talks to it over its standard input and output. This
kit is that conversation: you say what each command does, and call the app
from inside a command as an ordinary function call.
from vitruvian_tool_kit import Tool
tool = Tool(version="0.1.0")
@tool.command("hello")
def hello(app):
app.notify.hud(icon="hand.wave", message="Hello")
tool.run()
- One call per message.
app.notify.hud(...),app.clipboard.read_text(),app.storage.get(key=...): each is one request of the protocol, named as the protocol names it. The app may refuse any of them; the call then raisesRefusal. RaiseCommandRefused("why")to refuse a command yourself. - Synchronous, on one thread. A call to the app waits for its answer, ten
seconds at most. A handler must not be
async. - A tool can draw. With
"protocol": "2"andpanelsin its manifest,tool.panel("counter", on_open=..., on_event=...)says what a panel shows and what each thing the person does gives; a page istree(heading("Counter"), button("add", "Add one")), one function a kind of block. The handle sends a page unprompted withrenderand sets the tool's badge withbadge. - Never
print. Standard output is the link to the app. Write to standard error, or callapp.log(message=...).
Shipping it
The app starts a tool with Apple's python3 (/usr/bin/python3, Python
3.9), which has none of your packages. So the kit goes inside the tool's
folder, and the program finds it there:
python3 -m pip install --target lib vitruvian-tool-kit
import os, sys
HERE = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(HERE, "..", "lib"))
vitruvian-tool init --template python-kit writes a tool set up this way.
The kit needs nothing but the standard library and Python 3.9 or later.
The whole guide, the protocol and the other kits are in the SDK. MIT licence.
Metadata
Release files for vitruvian-tool-kit 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vitruvian_tool_kit-1.1.0.tar.gz | 31.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vitruvian_tool_kit-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 66.3 kB
Release files / vitruvian_tool_kit-1.1.0.tar.gz
| Download URL | vitruvian_tool_kit-1.1.0.tar.gz |
|---|---|
| Size | 31.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d8b82241ed9268685f712074e1ea4014854a877988d29ba1979330e079624c65
|
|
BLAKE2b-256 checksum How to use checksums |
14569ac724f989b2c9d300d4b92dfc30e06bf3cdbd48bf878820bfaf93786ace
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / vitruvian_tool_kit-1.1.0-py3-none-any.whl
| Download URL | vitruvian_tool_kit-1.1.0-py3-none-any.whl |
|---|---|
| Size | 34.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc969a3e22f351b066169e903ccc2d61f46e211927ca12221bfe19fac4b10309
|
|
BLAKE2b-256 checksum How to use checksums |
0797d7081d0c5a7649c1978f33144c2a6226ef8965901f9fcbd9b40619324a68
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.13.0 {"installer":{"name":"uv","version":"0.13.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|