Tk - Canvas Bitmap Widget


Bitmap widget is used to add bitmap to canvas. The syntax for bitmap widget is shown below −

canvasName create bitmap x y options

x and y set the location of bitmap −


The options available for the bitmap widget are listed below in the following table −

Sr.No. Syntax & Description

-anchor position

The bitmap will be positioned relative to the x and y locations. Center is default an other options are n, s, e, w, ne, se, sw, and nw.


-bitmap name

Defines the bitmap to display. The available bitmaps in Tk include warning, question, questhead, info, hourglass, error, gray12, gray25, gray50, and gray75.

A simple example for bitmap widget is shown below −


canvas .myCanvas -background red -width 100 -height 100 
pack .myCanvas
.myCanvas create bitmap 50 50 -bitmap info

When we run the above program, we will get the following output −

Canvas Bitmap Example