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

How to set the font size in Tkinter?

  • Tanvi BugdaniTanvi Bugdani
  • October 19, 2022
  • Tkinter
How to set the font size in Tkinter?

In this article, we are going to learn how to change the font size of the text in Tkinter. Font size refers to how large the characters displayed on the screen are. It is crucial to use proper font size in order to gain the reader’s attention wherever needed. So let’s see the different ways using which we can change the font size of text using Tkinter.


Method 1: Changing Tkinter font size using the font as a tuple

import tkinter as tk
from tkinter import *

#main window
root = Tk()
#title of the window
root.title("Tkinter Font Size")

#adding a label
l = Label(root, text="This is a sample line with font size 15.", width=40,
            height=5, font=('Times New Roman', 15, 'bold'))
l.pack()

root.mainloop()

Output:

Font Size Tuple Output
Font Size Tuple Output

In the above code, we have created a very basic GUI and added a label to it. Label widgets have an inbuilt property of font(‘font family’, size, ‘font style’). Font acts as a parameter in the code above. If not mentioned explicitly, the parameters will have their default values. In the above code, we have only used the size property and set the size to 15.


Method 2: Changing tkinter font size using the font as an object

Recommended Read: Tkinter Font Class Tutorial

import tkinter as tk
from tkinter import *
import tkinter.font as tkFont

#main window
root = tk.Tk()
#title of the window
root.title("Tkinter Font Size")

#creating a font object
fontObj = tkFont.Font(size=28)

#adding a label
l = Label(root, text="This is a sample line with font size 28.",
            width=40, height=5, font=fontObj)
l.pack()

root.mainloop()

Output:

Font Size Object Output
Font Size Object Output

Here, we have created an object of the Font class named fontObj and set the font size to 28. Later, in the label, we assigned the value of parameters for the font to be equal to the font object (fontObj) and hence, in the output, the font size is 28. In addition to size, we can also mention the font family and style as required.


Method 3: Using changing fonts using a custom class

import tkinter as tk
from tkinter import *
from tkinter.font import Font

#creating a custom class
class cl:
    def __init__(self, master) -> None:
        self.master = master
        #setting the font size to be 40
        self.customFont = Font(size=40)
        Label(self.master, text="Font size in the custom class is 40.",
                font=self.customFont).pack()
#end of custom class

if __name__ == "__main__":
    #main window
    root = tk.Tk()
    #title of the window
    root.title("Tkinter Font Size")
    #adding a label
    l = Label(root, text="This is a sample line with default font size.",
                width=40, height=5)
    l.pack()
    #calling our class object
    customSize = cl(root)

    root.mainloop()

Output:

Font Size Custom Class Output
Font Size Custom Class Output

In the above example, we have defined a custom class (cl), inside which we have a constructor where we assign the font size to 40. A label is also created with the font parameter being equal to the customFont.

In the main function, we first created a label with no explicit mention of the size of the text. Hence, it has the default size. After this, we call the cl class by creating its object customSize. On creating a new instance or object, the label with font size 40 is also displayed in the output along with the default size label.

Every time a new instance of the class is created, the label with font size 40 will be displayed as it is a part of the constructor of the class here. We can also set the font family and style inside the class itself.


Summary

In this way, we have understood how to change the font size in Tkinter in multiple ways. It is an easy topic to understand and implement. Please check out our other Tkinter tutorials here.

Tanvi Bugdani
Tanvi Bugdani
Articles: 63
Top 10 Best Laptop for Python Programming – Buying Guide
Previous Post Top 10 Best Laptop for Python Programming – Buying Guide
Next Post Curve fitting in Python: A Complete Guide
Curve fitting in Python: A Complete Guide

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.