Python Tutorial

Understanding Shapes, Images, Icons in Tkinter

Drawing Shapes With Tkinter Canvas

For the creation of simple shapes in Python Tkinter, you can use the Canvas class and certain functions available in this class. Before you create any shape using Canvas, it is essential to have a Canvas object packed to the main window. 

Canvas Methods for shapes: 

  • Canvas.create_oval(x1, y1, x2, y2, options = …): It's used to make an oval, a pieslice, and a chord.

  • Canvas.create_rectangle(x1, y1, x2, y2, options = …): It is used to make rectangle and square shapes.

  • Canvas.create_arc(x1, y1, x2, y2, options = …): This is what is utilised to make an arc.

Canvas.create_polygon(coordinates, options = …): This may be used to generate any valid shape.

Image and Icons With Tkinter

Any Tkinter/toplevel window's title bar icon is set with the iconphoto() function. However, any picture used as the titlebar's icon must be a PhotoImage class object.


iconphoto(self, default = False, *args)


Did you find this article helpful?