The ImageTk Module

This module contains support to create and modify Tkinter BitmapImage and PhotoImage objects.

For examples, see the demo programs in the Scripts directory.

The BitmapImage Class

BitmapImage (constructor)

BitmapImage(image, options). Create a Tkinter-compatible bitmap image, which can be used everywhere Tkinter expects an image object.

The given image must have mode "1". Pixels having value 0 are treated as transparent. Options, if any, are passed to Tkinter. The most commonly used option is foreground, which is used to specify the colour for the non-transparent parts. See the Tkinter documentation for information on how to specify colours.

The PhotoImage Class

PhotoImage (constructor)

PhotoImage(image). Creates a Tkinter-compatible photo image, which can be used everywhere Tkinter expects an image object. If the image is an RGBA image, pixels having alpha 0 are treated as transparent.

PhotoImage(mode, size). Creates an empty (transparent) photo image object. Use paste to copy image data to this object.

paste

paste(image, box). Pastes an image into the photo image. The box is a 4-tuple defining the left, upper, right, and lower pixel coordinate. If the box is omitted, or None, all of the image is assumed. In any case, the size of the pasted image must match the size of the region. If the image mode does not match the photo image mode, conversions are automatically applied.