AutoSkill Python 28x28 Drawing to NumPy Array GUI

Create a Python GUI using Tkinter and PIL that provides a 28x28 pixel drawing surface, handles color inversion, and exports the drawing as a NumPy array with specific UI feedback.

install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/python-28x28-drawing-to-numpy-array-gui" ~/.claude/skills/ecnu-icalk-autoskill-python-28x28-drawing-to-numpy-array-gui && rm -rf "$T"
manifest: SkillBank/ConvSkill/english_gpt4_8_GLM4.7/python-28x28-drawing-to-numpy-array-gui/SKILL.md
source content

Python 28x28 Drawing to NumPy Array GUI

Create a Python GUI using Tkinter and PIL that provides a 28x28 pixel drawing surface, handles color inversion, and exports the drawing as a NumPy array with specific UI feedback.

Prompt

Role & Objective

You are a Python GUI developer specialized in Tkinter and PIL. Your task is to build a drawing application that allows users to draw on a 28x28 pixel grid and convert the drawing into a NumPy array.

Operational Rules & Constraints

  1. Grid & Canvas: The application must feature a drawable surface representing a 28x28 pixel grid. The visual canvas should be scaled up (e.g., 280x280 pixels) for usability, but the underlying data must remain 28x28.
  2. Drawing Logic: The paint function must draw rectangles where the size corresponds exactly to one original pixel (pixel-perfect drawing).
  3. Color Handling: The application must handle color inversion. If the image is initialized with inverted colors (white pixels appearing as black), the conversion function must invert the NumPy array back to the original color scheme.
  4. Controls:
    • Include a "Convert" button to generate the 28x28 NumPy array.
    • Include a "Reset" button to clear the canvas and re-initialize the image.
  5. Output & Feedback:
    • Display the converted image in a separate window (using Toplevel).
    • Include a text label that displays a static message updating upon conversion or reset.
  6. Libraries: Use Tkinter for the GUI and PIL (Pillow) for image handling and NumPy for array conversion.

Triggers

  • build a python gui for 28x28 drawing
  • convert drawing to numpy array
  • create a mnist drawing tool
  • python tkinter drawing canvas to array