算法艺术创作
algorithmic-art
通过代码和可调参数创作生成艺术与交互式视觉效果。
textual-screenshot【设计与创意】Capture a Textual terminal UI as an SVG using its headless test harness. Use when asked to make, attach, or preview a screenshot of deepagents-code/dcode or another Textual app, visually verify a TUI state, or render a modal, screen, or widget without a desktop or browser.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Render the real app with Textual's headless test harness, drive it to the requested state, and save the composed terminal as SVG. Prefer this over browser automation or OS-level screenshot tools.
App class and the shortest trusted local setup that reaches the requested UI.app.run_test(size=(columns, rows)).await pilot.pause() after startup and after every action that changes visible state. Use pilot.press(...) for a realistic interaction path when practical; direct app methods are acceptable for a focused preview.app.save_screenshot(output_path) while the desired state is visible. Use an .svg path.Minimal deepagents-code example:
import asyncio
import os
from pathlib import Path
from tempfile import TemporaryDirectory
from unittest.mock import AsyncMock, MagicMock, patch
async def main() -> None:
output = Path("/tmp/dcode-ui.svg")
with TemporaryDirectory() as profile:
os.environ["DEEPAGENTS_HOME"] = profile
from deepagents_code.app import DeepAgentsApp
app = DeepAgentsApp(agent=MagicMock())
with patch.object(app, "_post_paint_init", new=AsyncMock()):
async with app.run_test(size=(110, 36)) as pilot:
await pilot.pause()
await app._handle_command("/model")
await pilot.pause()
app.save_screenshot(output)
print(output)
asyncio.run(main())
Run from libs/code so the project environment and editable package resolve:
uv run python /tmp/capture_dcode_ui.py
Adapt only the app constructor and action that opens the target state. For a standalone Textual app, import its App subclass and use the same run_test/save_screenshot sequence.
DeepAgentsApp, set DEEPAGENTS_HOME to a temporary directory before importing deepagents_code, and mock _post_paint_init before mounting; replacing only the agent does not isolate startup side effects.(110, 36) and adjust only when the target clips or wastes substantial space.await pilot.pause() rather than using arbitrary sleeps.