In this tutorial in Tkinter , you can change the font size of widgets using the font parameter in various widget constructors or methods. Here’s an example demonstrating how to change the font size of a label widget.
import tkinter as tk from tkinter import font root = tk.Tk() root.title("Tkinter Font Size Example") custom_font = font.Font(family="Helvetica", size=24) label = tk.Label(root, text="Hello, Tkinter!", font=custom_font) label.pack(pady=20) root.mainloop()
To change the font size in Tkinter
In this example, we import the Tkinter module and the font submodule. We create the main window using tk.Tk(). We define a custom font using font. Font(), specifying the font family and size. We create a Label widget and set its font parameter to the custom font. We use the pack method to place the label in the window and start the Tkinter event loop with root.mainloop().
Output:–
This will display a window with the text “Hello, Tkinter!” in Helvetica font with a size of 24.