Skip to main content

JAnim Stdio Interact

MIT License PyPI Latest Release

> English < | 简体中文

A utility library for interacting with JAnim GUI and managing windows via standard input/output

Basic Usage

Interact with the JAnim GUI by passing JSON commands via stdio to open and close specific instances.

First, start the janim-stdio-i program:

janim-stdio-i host

For example, to compile a code snippet and build the Timeline within it for display in a preview window, send the following to stdin:

{"type": "execute", "key": "id1", "source": "from janim.examples import *\nclass A(HelloJAnimExample): pass"}

You will see a preview window open displaying the classic HelloJAnimExample.

Here, "key": "id1" is used for window reuse. If you send an execute command with the same key, the Timeline in the existing window will be replaced without opening a new window.

{"type": "execute", "key": "id1", "source": "from janim.examples import *\nclass A(RotatingPieExample): ..."}

Sending the command above replaces the HelloJAnimExample in the original window with RotatingPieExample.

If we use a different key, for example:

{"type": "execute", "key": "id2", "source": "from janim.examples import *\nclass A(ArrowPointingExample): ..."}

A new window will open. Essentially, one key corresponds to one window.

In addition to compiling and building Timelines via stdin, information generated by the GUI is returned via stdout. See below for details.

API Reference

stdin

  • "type": "execute"

    Required parameters:

    • "key": Unique identifier for the window.
    • "source": Source code for compilation.

    Compiles and builds the Timeline to display in the preview window.

    If the window corresponding to key already exists, the original Timeline in that window is replaced with the new one.

    Example:

    {"type": "execute", "key": "id1", "source": "from janim.examples import *\nclass A(HelloJAnimExample): pass"}
    
  • "type": "close"

    Required parameters:

    • "key": Unique identifier for the window.

    Closes the window corresponding to key.

    Example:

    {"type": "close", "key": "id1"}
    

stdout

{"type": "viewer-msg", "key": "...", "from": "...", "janim": { ... }}
Field Type Description
type string Fixed as "viewer-msg", identifying the message category
key string Corresponds to the identifier key used during creation
from string Sender source. Possible values: "execute", "close", "gui"
janim object The specific event payload, containing the event type and data

When "from": "execute", it represents the result of the execute command sent to stdin:

  • When source code compilation fails, the payload is

    "janim": {"type": "error", "reason": "compile-failed"}
    
  • When the source code contains no usable Timeline, the payload is:

    "janim": {"type": "error", "reason": "no-timeline"}
    
  • When the Timeline build fails, the payload is:

    "janim": {"type": "error", "reason": "build-failed"}
    
  • When execution is successful, the payload is:

    "janim": {"type": "success"}
    

When "from": "close", it represents the result of the close command sent to stdin:

  • When no preview interface is found for the identifier, the payload is:

    "janim": {"type": "error", "reason": "not-found"}
    
  • When executed successfully, the payload is:

    "janim": {"type": "success"}
    

When "from": "gui", it represents information generated by the GUI:

  • When the interface is created, the payload is:

    "janim": {"type": "created"}
    
  • When the interface content is replaced, the payload is:

    "janim": {"type": "rebuilt"}
    
  • When the preview progress changes, the payload is:

    "janim": {"type": "lineno", "data": <current_line_number>}
    
  • When the interface is closed, the payload is:

    "janim": {"type": "close_event"}
    

Metadata

Release files for janim-stdio-interact 0.2.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 janim-stdio-interact 0.2.0
File Size Uploaded Provenance Actions
janim_stdio_interact-0.2.0.tar.gz 9.8 kB Without provenance Details for janim_stdio_interact-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for janim-stdio-interact 0.2.0
File Interpreter ABI Platform Actions
janim_stdio_interact-0.2.0-py3-none-any.whl Python 3 none any Details for janim_stdio_interact-0.2.0-py3-none-any.whl

Total release size: 21.6 kB

Release files / janim_stdio_interact-0.2.0.tar.gz

Download URL janim_stdio_interact-0.2.0.tar.gz
Size 9.8 kB
Tags Source
SHA-256 checksum
How to use checksums
36581ef5ff4d5ed968e7f2fa2294ebd35e974a7944e4e0f9d9981a122efd3f5d
BLAKE2b-256 checksum
How to use checksums
af6e6ffa28d5e47c6c92c83444128fdf2edd4bf8b7369421f198ad12ce865996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Release files / janim_stdio_interact-0.2.0-py3-none-any.whl

Download URL janim_stdio_interact-0.2.0-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a115fa6e9b5942556c452489cf8f53dcf5b034db13c73a2751484a42ea931e57
BLAKE2b-256 checksum
How to use checksums
e46d9f948b0eb048133ee23f1fa468146329fece397e602f9c1e1982101e383d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via python-requests/2.34.2

Security for janim-stdio-interact 0.2.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.

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