We can show a JPG image in a label widget by loading an image file.
1 2 3 4 5 6 7 8 91011121314151617
importtkinterastkfromtkinterimportttkfromPILimportImage,ImageTkmyfile=r"/images/pizza.JPG"root=tk.Tk()withImage.open(myfile)asimg:# Load the image into a format that Tk uses.tk_pizza=ImageTk.PhotoImage(img)lbl_test=ttk.Label(root,image=tk_pizza)lbl_test.pack()root.mainloop()
If we want to show the image and some text in the label, we need to use the compound setting.