Open In App

How to Display Images within Tkinter Frames

Last Updated : 24 Jun, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Tkinter is a Python module used to create Graphical User Interface (GUI) applications. Tkinter has many widgets such as Button, Label, Text, Entry, Frame, Checkbox and more that make it easy and quick to develop desktop applications.

How to Insert Image inside Frame in Tkinter?

To insert an image inside a frame is the same as inserting an image in Tkinter root GUI. The parent of the widget containing the image must refer to the frame name.

Example:

In this example, initially, we are creating a Frame in the GUI window. Then place an image in a Label widget. Then the label widget is placed inside the frame in Tkinter.

Python
# Importing Tkinter
import tkinter as tk
# GUI
root = tk.Tk()
root.title("GFG")
root.geometry("400x200")
# Convert image to PhotoImage variable.
gfg_picture = tk.PhotoImage(file="geeksforgeeks-logo.png")
# Frame created.
frame1 = tk.Frame(root, width=300, height=150)
frame1.pack()
# Label within the frame containing the image.
label1 = tk.Label(frame1, image=gfg_picture)
label1.pack()
root.mainloop()

Output:

insert_image_in_frame_tkinter_output_pic_1
GUI window with image inside frame


Next Article
Article Tags :
Practice Tags :

Similar Reads