Skip to main content

A cross-platform PTY/ConPTY terminal for Jupyter with bundled xterm.js

Project description

Notebook Terminal 0.3.4

A real PTY/ConPTY terminal embedded in Jupyter using bundled xterm.js and only standard ipywidgets channels. It needs no anywidget, JupyterLab extension, administrator installation, HTTP server, WebSocket, CDN, or internet connection.

Installation

python -m pip install notebook_terminal-0.3.4-py3-none-any.whl

Restart the kernel after replacing an older version.

Usage

from notebook_terminal import terminal
term = terminal(height=450, interactive=True)

The shell prompt, username, host, and working directory come from the actual PowerShell, CMD, Bash, or Zsh process. They are not hardcoded.

0.5.0 transport changes

  • lossless output packets with sequence numbers and acknowledgements;
  • every frontend state contains all unacknowledged packets, so coalesced widget updates cannot drop output;
  • exact byte transport preserves split UTF-8 and ANSI sequences;
  • output batching every 25 ms and maximum 64 KiB packets;
  • ordered, acknowledged input queue prevents lost keystrokes;
  • xterm writes are serialized and acknowledged only after rendering;
  • resize events and terminal control messages remain deduplicated.

This release specifically addresses missing characters, overwritten output, invisible fast commands such as ls, and severe lag caused by sending every PTY fragment as an independent widget trait update.

Repository

GitHub: ZawadzkiR/notebook-terminal

Passing arguments to Python files

term.run_python_file(
    "script.py",
    args=["input.csv", "value with spaces", 123],
)

The script receives:

import sys
print(sys.argv)
# ['script.py', 'input.csv', 'value with spaces', '123']

Named options can be generated with kwargs:

term.run_python_file(
    "train.py",
    args=["dataset.csv"],
    kwargs={
        "epochs": 100,
        "learning_rate": 0.001,
        "verbose": True,
        "dry_run": False,
        "tag": ["baseline", "test"],
    },
    rich_output=True,
)

This produces arguments equivalent to:

python train.py dataset.csv --epochs 100 --learning-rate 0.001 --verbose --tag baseline --tag test

Rules:

  • values in args are converted to strings and passed separately;
  • underscores in kwargs keys become hyphens;
  • keys already beginning with - are preserved;
  • True creates a flag;
  • False and None omit the option;
  • list and tuple values repeat the option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notebook_terminal-0.3.5.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

notebook_terminal-0.3.5-py3-none-any.whl (1.6 MB view details)

Uploaded Python 3

File details

Details for the file notebook_terminal-0.3.5.tar.gz.

File metadata

  • Download URL: notebook_terminal-0.3.5.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.0

File hashes

Hashes for notebook_terminal-0.3.5.tar.gz
Algorithm Hash digest
SHA256 c8e0703e93742f2c04a264b2ca6e3a2c843cb904f07ca111514b5908fbee70ee
MD5 ec5aa5885bdb5c40a2cfff038edbcbcb
BLAKE2b-256 46ff7431f26a28c98a6d60ec984355b060db5548bbb2d2f81ff7836ea6e801dc

See more details on using hashes here.

File details

Details for the file notebook_terminal-0.3.5-py3-none-any.whl.

File metadata

File hashes

Hashes for notebook_terminal-0.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 8f148d77b915edae3758a6655d2b0ae094a66328d3e077e8e0810023ae527b13
MD5 d584fb32d0f91ed93853977afe5730da
BLAKE2b-256 1a79ff6509d190f82d5706dda383c8a6619d982f96d5f2a4f41eded7d8269f09

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page