Chapter 9. The Canvas Widget

The canvas widget is mainly used for drawing items such as arcs, lines, rectangles, circles, and so on. You can also place text and other widgets inside a canvas widget. Think of it as a painter's canvas: It is blank until you decide to draw something on it. But unlike a painter's canvas, which is limited in size, this canvas is scrollable in any direction. Here are some examples of how you can use a canvas widget:

  • Create a drawing program.

  • Display a graph based on input from the user.

  • Create a customized slider.

Each item you create in a canvas widget can have bindings attached to it to allow for easy interaction with the user.

Get Learning Perl/Tk now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.