- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Python Tkinter – How do I change the text size in a label widget?
Tkinter Label Widgets are used to create labels in a window. We can style the widgets using the tkinter.ttk package. In order to resize the font-size, font-family and font-style of Label widgets, we can use the inbuilt property of font(‘font-family font style’, font-size).
Example
In this example, we will create buttons that will modify the style of Label text such as font-size and font-style.
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("650x250") #Define all the functions def size_1(): text.config(font=('Helvatical bold',20)) def size_2(): text.config(font=('Helvetica bold',40)) #Create a Demo Label to which the changes has to be done text=Label(win, text="Hello World!") text.pack() #Create a frame frame= Frame(win) #Create a label Label(frame, text="Select the Font-Size").pack() #Create Buttons for styling the label button1= Button(frame, text="20", command= size_1) button1.pack(pady=10) button2= Button(frame, text="40", command=size_2) button2.pack(pady=10) frame.pack() win.mainloop()
Output
Running the above code will display a window containing a text Label. The buttons can be used to change the font-size of the text label.
Now, select to change the font-size of the Text Label widget.
- Related Articles
- How do I center the text in a Tkinter Text widget?
- How to change the size of text on a label in Tkinter?
- How do I give focus to a python Tkinter text widget?
- Underline Text in Tkinter Label widget
- How do I change button size in Python Tkinter?
- How to update a Python/tkinter label widget?
- How to change the color of certain words in a Tkinter text widget?
- How to change Tkinter label text on button press?
- How to highlight text in a tkinter Text widget?
- How to update the image of a Tkinter Label widget?
- Change the focus from one Text widget to another in Tkinter
- Python Tkinter – How to display a table editor in a text widget?
- How to change a Tkinter widget's font style without knowing the widget's font family/size?
- How do I get the background color of a Tkinter Canvas widget?
- How to set the height/width of a Label widget in Tkinter?

Advertisements