capturing-tk-screenshots-headless
Installation
SKILL.md
Capturing Tk screenshots headless
Overview
Run the GUI on a virtual X server (Xvfb) and capture with ImageMagick import. There is no window manager: no title bars, every window opens at 0,0, and import -window <id> copies whatever is on screen in that window's rectangle, including other windows covering it.
Before you start
- Use a Python that has tkinter:
python -c "import tkinter". Sandbox systempython3often lacks it; a venv with Thonny orpython3-tkhas it. - Tools:
Xvfb,xvfb-run,import,convert(ImageMagick). Often missing:xdotool,xwininfo,scrot. Don't plan on them.