Skip to main content

Python SDK

Layer constructors return a Composite: {layers, data}. Declarations contain only id, type and dataPath; the addressed objects contain layout, content and style. Merge layer results and chart components with the same merge function, then finalize with toResponse (to_response in snake_case APIs). An explicit dataPath chooses the object location; otherwise it is derived from id.

Matrix.to_part() returns {content: MatrixData}. Place it with place / Place to give its node a frame and data path. The node's content holds pixels, default, batch and layout; matrix style is empty. Image and image-backed icon nodes use content.url. Bind an editor layer to a partial node in data without adding a remote declaration. Omitted or null values keep the saved editor value; objects merge field by field, arrays replace, and a supplied frame replaces the whole frame and must include width and height. Each response starts from the saved configuration.

Pure Python 3.9+, using only the standard library.

python3 -m pip install glance-widgets-sdk
import json
from glance_widgets import Box, merge, pixel_text_root, pixel_progress_bar, place, to_response

canvas = {"width": 338, "height": 158}
root = pixel_text_root("12:30", {"canvas": canvas, "theme": "led"})
frame = Box.canvas(canvas).sub(0.1, 0.75, 0.8, 0.15).to_frame()
bar = pixel_progress_bar(65, {"canvas": canvas, "frame": frame})
badge = place(bar, {"id": "progress", "frame": frame, "path": "data.progress"})
response = to_response(merge(root, badge))
body = json.dumps(response, ensure_ascii=False, separators=(",", ":"))

API functions and methods use snake_case: to_response, labeled_pixel_ring_progress, Matrix.to_part(), Box.from_pt(). Arguments and returned protocol objects are dictionaries; their field names retain the TS/protocol spelling (fontSizeRatio, dataPath, onConflict, etc.). Box.canvas(canvas) creates a layout box. themes["led"] selects a theme, and custom pixel fonts use define_font().

See the shared guide for options and composition rules.

Fonts, icons, validation schemas and the measured text advance table are bundled as package data. Regenerate them from the checked-in TS blueprint/spec with:

python3 sdks/python/scripts/generate_data.py

This development command needs the TypeScript SDK's installed compiler. The Python package itself does not invoke Node or depend on the repository layout.

Use layer_path(id) for the derived node path, and validate_layer_node(node, type) to validate a partial editor node before returning it.

Metadata

Release files for glance-widgets-sdk 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for glance-widgets-sdk 1.0.0
File Size Uploaded Provenance Actions
glance_widgets_sdk-1.0.0.tar.gz 95.9 kB Without provenance Details for glance_widgets_sdk-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for glance-widgets-sdk 1.0.0
File Interpreter ABI Platform Actions
glance_widgets_sdk-1.0.0-py3-none-any.whl Python 3 none any Details for glance_widgets_sdk-1.0.0-py3-none-any.whl

Total release size: 202.7 kB

Release files / glance_widgets_sdk-1.0.0.tar.gz

Download URL glance_widgets_sdk-1.0.0.tar.gz
Size 95.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4f12dd9ce5c3a197116990ff639604774b2506e9edcd23bc5794e9d0ce6cdef4
BLAKE2b-256 checksum
How to use checksums
24bdbd022f58fe58960ac6c7cd5ac329247375e16a6f7d8e8412162983d168e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / glance_widgets_sdk-1.0.0-py3-none-any.whl

Download URL glance_widgets_sdk-1.0.0-py3-none-any.whl
Size 106.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d0bbdf6eb9839a2d9afd1a302f607f2cfb247cb0725827120982fa3214913780
BLAKE2b-256 checksum
How to use checksums
3242b421e62928253583fcd073885ec7276240e839e38f9d60875aa84f6f2ac1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for glance-widgets-sdk 1.0.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page