Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content
No results
  • About AskPython
  • Blog
  • Contact Me
  • Free Online Developer Tools Hub
  • Home
  • Meet the Team
  • Privacy Policy
  • Python
  • Python Course for Beginners Online FREE
  • Python Tutorial – Mega Index
  • Terms and Conditions

🚀 Supercharge your YouTube channel's growth with AI.

Try YTGrowAI Free
  • Home
  • Blog
  • About AskPython
  • Python Course
  • Start Here

Tkinter Frame and Label: An easy reference

  • AnuAnu
  • August 5, 2020
  • Tkinter
Tkinter Frame and Label: An easy reference

In this article, we’ll talk about the Tkinter Frame and Label widgets.

Let’s Talk About the Tkinter Frame and Label Widgets

We’ll go over both the widgets one by one to understand the fundamentals

What is a Tkinter Frame?

A frame in tkinter is a widget that appears as a rectangular area on the screen. This widget serves as a base for the placement of other widgets such as Labels, Checkbuttons, RadioButtons, etc. Tkinter frame widgets are basically used to group the other widgets on the screen.

Frames are not only used for widgets, they can also be used to place video overlays and other external processes. The frame widget has various properties such as background color, height and width.

Coding a Tkinter Frame

Here’s an example for the Frame is as shown below.

from tkinter import *

root=Tk()

frame = Frame(width=100, height=100, bg="red", colormap="new")
frame.pack(side=LEFT)

# set size of window
root.geometry('500x500')

# set an infinite loop so window stays in view
root.mainloop()
Output For Frame Example
Output For Frame Example

The small red box on the left side of the output is the tkinter frame that we created. Let’s move on to creating a label widget.

What is a Tkinter Label?

Tkinter provides the Label widget to insert any text or images into the frame. Tkinter allows several lines of text to be displayed on the frame however, only one choice of font to the user.

Labels are like typical text boxes and can be of any size. If the user defines the size, then the contents are adjusted within that size and if not it adjusts according to the length of your content on its own.

Labels have foreground and background fields to specify your choice of color. The syntax of the same is as shown below.

w = Label(root, text="Hey there", fg="red")

For background color make sure you use bg as the attribute.

Labels can be used to display PhotoImages and BitMapImages. The syntax for this is also shown below.

photo = PhotoImage(file="welcome.jpg")
w = Label(root, image=photo)
w.photo = photo

Coding a Label

from tkinter import *

root=Tk()

label1 = Label(root, text="hi, welcome to GUI using Tkinter")
label1.pack()

root.geometry('500x400')
root.mainloop()

The output of the above code is as shown below.

Output For Label Example
Output For Label Example

Implementing Tkinter Frame and Label Widgets

from tkinter import *

root=Tk()

root.title("My first GUI")

# set resizing to false
root.resizable(width=FALSE, height=FALSE)

# set size of window
root.geometry('500x400')

leftFrame = Frame(root)
leftFrame.pack(side=LEFT)

rightFrame = Frame(root)
rightFrame.pack(side=RIGHT)

label1 = Label(leftFrame, text="Left column")
label1.pack()

label3 = Label(leftFrame, text="Column content")
label3.pack()

label2 = Label(rightFrame, text="Right column")
label2.pack()

# set an infinite loop so window stays in view
root.mainloop()

The output of the above code is as shown below.

Output For Hybrid Example
Output For Hybrid Example

Conclusion

This comes to the end of our tutorial on the creation of a Frame and Labels using Tkinter. Try out this code and let us know your feedback in the comment section below.

Anu
Anu
Articles: 24
File Uploads to Django – How to Upload Files to Django Server?
Previous Post File Uploads to Django - How to Upload Files to Django Server?
Next Post Python NumPy module - 4 Important Type of Functions to Know
Python NumPy module – 4 Important Type of Functions to Know

Related Posts

Tkinter IntVar – Tkinter Tutorial with Examples

Tkinter IntVar – Tkinter Tutorial with Examples

  • July 5, 2026
Tkinter StringVar with Examples – Tkinter Tutorial

Tkinter StringVar with Examples – Tkinter Tutorial

  • July 5, 2026
Tkinter GUI Widgets

Tkinter GUI Widgets

  • April 24, 2026

Partner Websites

  • GoLangDocs
  • LinuxForDevices
  • CodeForGeek

Popular Categories

  • Python Programming
  • Python Modules
  • OOPS in Python
  • Python Programming Examples
  • Strings in Python

Hall of Fame

  • Python Programming
  • OOPS in Python
  • Creating Python Modules
  • Args and Kwargs in Python
  • Python Dictionary (Dict) Tutorial
  • Python List – 15 Things You MUST Know
  • Python Set – Things You MUST Know
  • Python String Functions: Methods by Task

Important Links

  • Home
  • Python Course
  • Start Here
  • Blog
  • About AskPython
Latest posts
  • np.linalg.eig: Eigenvalues and Eigenvectors
  • What Does %s Mean in a Python Format String?
  • How to Use np.sin() in NumPy
  • cv2.imread: Load Images with OpenCV
  • pd.read_json: Read JSON Into a DataFrame

Copyright © 2026 - AskPython. All rights reserved.