Tkinter has three built-in Layout Managers that can be used to position labels containing images in a frame: pack, grid, and place. The BitmapImage class is used to display only monochrome (two-color) images in labels.For information on how you can work with more image formats, see the Pillow section below. Note that only GIF and PGM/PPM image formats are supported. The PhotoImage class is used to display grayscale or true color icons, as well as images in labels.
To display an image requires the use of Image and ImageTk imported from the Python Pillow (aka PIL) package.Ī label widget can display either PhotoImage or BitmapImage objects:
Tkinter’s label widget can be used to display either images or text. How to Display Images with Tkinter’s Label Widget The reason for this is because images in applications can vary from background wallpaper, to positioned images that represent processes in underlying code, to clickable images or icons that perform an action when clicked. Note that depending on the purpose of an image in a Tkinter application, different coding may be required. Using Pillow, a Tkinter function that displays a text-based message can instead display an image-based message. Tkinter relies on the Python Pillow (aka PIL) package for image processing capabilities.