Violit Drawable Konva
Violit widget wrapping the same Konva canvas used by
streamlit-drawable-konva
(0.4.0 tracks Streamlit 0.7.x standalone).
Requires Violit ≥ 0.8.29 (app.register_js_widget).
Features
vl_canvas— drawable Konva canvas (same tools asst_canvas)- In-canvas tool picker —
tools=[…]+display_tool_picker=True - Icon or label tools —
tool_picker_style="icons"|"labels" - Toolbar color pickers —
display_color_pickers=Truefor stroke/fill vl_image_comparison— before/after slider companion (same asst_image_comparison)- Background color / image (upload or sample)
- Scene
json_datawith coordinates (x/y/width/height/points) - Spline helpers:
splines_from_json,sample_spline, …
Demo uses dark theme. Pass Violit State / callables into vl_canvas
(not .value) so drawing mode and stroke update live. With
display_tool_picker=True, tools can also be switched on the canvas itself;
enable display_color_pickers for stroke/fill next to the tools.
Install (editable)
cd /devel/dev/cvrlab/violit-drawable-konva
uv venv .venv
source .venv/bin/activate
uv pip install -e ".[dev]"
Sync the browser IIFE from the Streamlit sibling build (required before demo / packaging):
# ensure standalone.js exists in streamlit-drawable-konva first
bash scripts/sync_standalone.sh
Until you sync, the package falls back to:
../streamlit-drawable-konva/streamlit_drawable_konva/frontend/build/standalone.js
Demo
source .venv/bin/activate
.venv/bin/violit run demo/app.py --reload --localhost --port 8031
# → http://localhost:8031
demo/app.py must end with app.run() (Violit does not auto-start the server).
Tests
pytest -q
Usage
import violit as vl
from violit_drawable_konva import ensure_registered, vl_canvas, vl_image_comparison
app = vl.App(title="Canvas", theme="dark")
ensure_registered(app) # optional; also called by vl_canvas / vl_image_comparison
drawing_mode = app.state("polygon", key="drawing_mode")
stroke_width = app.state(3, key="stroke_width")
stroke_color = app.state("#111", key="stroke_color")
bg_file = app.state(None, key="bg_file")
payload = app.state({"image_data_url": None, "json_data": None}, key="c1")
app.file_uploader("Background", type=[".png", ".jpg"], bind=bg_file)
result = vl_canvas(
app,
drawing_mode=drawing_mode, # State, not .value
stroke_width=stroke_width,
stroke_color=stroke_color,
background_image=bg_file, # UploadedFile / PIL / State / callable
height=400,
width=600,
tools=["freedraw", "line", "rect", "polygon", "transform", "pan"],
display_tool_picker=True,
tool_picker_style="icons",
display_color_pickers=True,
key="c1",
bind=payload,
)
# result.json_data / result.image_data
vl_image_comparison(app, img_before, img_after, width=600, key="cmp")
Helpers mirror the Streamlit package: crop_box_from_json, objects_by_group,
splines_from_json, spline_control_points, sample_spline, sample_catmull_rom.
Layout
violit_drawable_konva/
api.py # ensure_registered, vl_canvas, vl_image_comparison
payload.py / spline.py / helpers.py
static/standalone.js # synced IIFE (mount + mountImageComparison)
demo/app.py
tests/
scripts/sync_standalone.sh
Publish (PyPI)
cd /devel/dev/cvrlab/violit-drawable-konva
# 1) Sync JS from Streamlit build (after streamlit 0.7.x is built)
bash scripts/sync_standalone.sh
# 2) Tests
.venv/bin/python -m pytest -q
# 3) Commit & push
git add -A
git status
git commit -m "Release 0.4.0: icon tool picker and toolbar color pickers."
git push -u origin main
git tag v0.4.0 && git push origin v0.4.0
# 4) Build & publish
uv build
uv publish # needs UV_PUBLISH_TOKEN or interactive PyPI token
Verify: https://pypi.org/project/violit-drawable-konva/
Bump version in pyproject.toml before each new upload (PyPI versions are immutable).
Quick PyPI update (0.3.0 → 0.4.0)
bash scripts/sync_standalone.sh
uv build && uv publish
pip install -U violit-drawable-konva # expect 0.4.0
Manual port checklist
- Build Streamlit frontend (
npm run build) sostandalone.jsexists. bash scripts/sync_standalone.shuv pip install -e ".[dev]"(violit>=0.8.29)pytest -qviolit run demo/app.py --reload --localhost --port 8031- Commit / tag /
uv publish(see above)
Metadata
Release files for violit-drawable-konva 0.4.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 | Provenance | Actions |
|---|---|---|---|---|
| violit_drawable_konva-0.4.0.tar.gz | 161.2 kB | Without provenance | Details for violit_drawable_konva-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| violit_drawable_konva-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for violit_drawable_konva-0.4.0-py3-none-any.whl |
Total release size: 321.2 kB
Release files / violit_drawable_konva-0.4.0.tar.gz
| Download URL | violit_drawable_konva-0.4.0.tar.gz |
|---|---|
| Size | 161.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5b2062f4911323209bbd1eb570cb1a5ecd1e6e76c2884fa35e3d65b0faca9fb9
|
|
BLAKE2b-256 checksum How to use checksums |
b372884cd512c158a9547353b96c3369e3907d9116b777ff1daaf34b810b5ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / violit_drawable_konva-0.4.0-py3-none-any.whl
| Download URL | violit_drawable_konva-0.4.0-py3-none-any.whl |
|---|---|
| Size | 160.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5f0325126f24b460781d88744b57bdcfb1cc734cf919a8ba356816e0684491a8
|
|
BLAKE2b-256 checksum How to use checksums |
284e099e374adf75af39d8974cfac00f082350e6dc8346129015846ac6ae069f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"CachyOS Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for violit-drawable-konva 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.