Python GUI with tkinter: labels with text and Images

Here is the code to put an image and a text into a label, together. The parameter to use is compund, but look at the code and the video to see what is this about.

# Label with text and image


import tkinter as tk

root = tk.Tk()
img = tk.PhotoImage(file="excel.png")
lab = tk.Label(root, text="Hello")
lab.grid()
lab["compound"] = tk.LEFT
lab["image"] = img

root.mainloop()



This is the window

The video


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.