Tkinter Entry - Set Font Size


Tkinter Entry - Set Font Size

In Tkinter, you can set the font size of text displayed in an Entry widget with a required value.

Tkinter Entry with font size = 24
Tkinter Entry with font size = 24

To set the font size of an Entry widget in Tkinter, first create a font object with required font size. Then, create an Entry widget with font option set with the font object.

custom_font = font.Font(size=24)
entry = tk.Entry(window, font=custom_font)

import font from tkinter before using Font class.

In this tutorial, you will learn how to set the font size of an Entry widget, with examples.

Examples

1. Set font size of Entry widget to 24

In this example, we create a basic Tk window with an Entry widget and set its font size to 24.

Python Program

import tkinter as tk
from tkinter import font

# Create the main window
window = tk.Tk()
window.title("PythonExamples.org")
window.geometry("350x250")

label = tk.Label(window, text="Enter your input")
label.pack()

# Create a Font object with the desired font size
custom_font = font.Font(size=24)

# Create an Entry widget with specific font
entry = tk.Entry(window, font=custom_font)
entry.pack()

# Run the application
window.mainloop()

Output

In Windows

In MacOS

Tkinter Entry with font size = 24
Tkinter Entry with font size = 24

Summary

In this Python Tkinter tutorial, we have seen how to set the font size of an Entry widget in Tkinter, with examples.