Lesson 5/6 · Graduation exam preparationNot startedhigh School~150 min

Graphics with tkinter

Drawing on a canvas, mouse clicks, buttons, text fields and timer animations. The programs run in a tkinter simulation right in the browser, so you see the result immediately.

After this lesson you'll be able to:

  • Draw lines, rectangles, ovals, polygons and text on a `Canvas`
  • React to the mouse with `bind` and to a button with `command`
  • Animate with `after` and `update`

Theory (PDF)

The theory for this lesson is being prepared.

Examples to try

Your code runs only in this browser, in an isolated environment with no access to the internet or your account.

A canvas and clicks

Run the program and click the window - every click draws a dot. Every task in this lesson works like this.

Ctrl+Enter runs the program. Tab indents. Press Esc, then Tab, to leave the editor.

Python starts the first time you run code.

Output