Next / Previous / Contents

8.8. Canvas bitmap objects

A bitmap object on a canvas is shown as two colors, the background color (for 0 data values) and the foreground color (for 1 values).

To create a bitmap object on a canvas C, use:

    id = C.create_bitmap(x, y, *options ...)

which returns the integer ID number of the image object for that canvas.

The x and y values are the reference point that specifies where the bitmap is placed.

Options include:

Table 8. Canvas bitmap options

activebackground These options specify the background, bitmap, and foreground values when the bitmap is active, that is, when the mouse is over the bitmap.
activebitmap
activeforeground
anchor The bitmap is positioned relative to point (x, y). The default is anchor=tk.CENTER, meaning that the bitmap is centered on the (x, y) position. See Section 5.5, “Anchors” for the various anchor option values. For example, if you specify anchor=tk.NE, the bitmap will be positioned so that point (x, y) is located at the northeast (top right) corner of the bitmap.
background The color that will appear where there are 0 values in the bitmap. The default is background='', meaning transparent.
bitmap The bitmap to be displayed; see Section 5.7, “Bitmaps”.
disabledbackground These options specify the background, bitmap, and foreground to be used when the bitmap's state is tk.DISABLED.
disabledbitmap
disabledforeground
foreground The color that will appear where there are 1 values in the bitmap. The default is foreground='black'.
state By default, items are created with state=tk.NORMAL. Use tk.DISABLED to make the item grayed out and unresponsive to events; use tk.HIDDEN to make the item invisible.
tags If a single string, the bitmap is tagged with that string. Use a tuple of strings to tag the bitmap with multiple tags. See Section 8.4, “Canvas tags”.