Tk - Canvas Bitmap Widget


Advertisements

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 −

Options

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

Sr.No. Syntax & Description
1

-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.

2

-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 −

#!/usr/bin/wish

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
tk_canvas_widgets.htm
Advertisements