Files

29 lines
775 B
Python

"""Drives examples/demo_tui.py inside tmux and captures a couple of PNG frames.
Run with: uv run python examples/run_demo.py
"""
import time
from pathlib import Path
from tmux_shot import TmuxApp
ROOT = Path(__file__).resolve().parent.parent
OUT = ROOT / "out"
OUT.mkdir(exist_ok=True)
DEMO_SCRIPT = Path(__file__).resolve().parent / "demo_tui.py"
app = TmuxApp("tmux_shot_demo", command=f"python3 {DEMO_SCRIPT}", width=80, height=24)
time.sleep(0.3) # let curses draw the first frame
app.screenshot(OUT / "demo_1.png")
for key in ("Down", "Down", "Right", "Right", "Right"):
app.send_keys(key, enter=False)
time.sleep(0.2)
app.screenshot(OUT / "demo_2.png")
app.send_keys("q")
app.kill()
print(f"wrote {OUT / 'demo_1.png'}")
print(f"wrote {OUT / 'demo_2.png'}")