- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the font on ttk.Entry in Tkinter?
There are times when a user wants to insert the information like Name, contact number, Email, address, etc. Tkinter has a simple way to handle these types of inputs through its Entry widgets. Tkinter Entry widgets can be styled using the ttk package.
To change other properties of the Entry widgets such as font properties, text-size, and font-style, we can use the font(‘font-family font-size font-style’) attribute. We can specify the font property in the entry constructor.
#Import tkinter library from tkinter import * from tkinter import ttk #Create an instance of tkinter frame or window win= Tk() #Set the geometry of tkinter frame win.geometry("750x250") #Create an Entry Widget entry= ttk.Entry(win,font=('Century 12'),width=40) entry.pack(pady= 30) win.mainloop()
Executing the above code will display a window that contains a customized Entry widget.
To change the font property, we can modify the values of the font attributes in the code.
- How to change the color of ttk button in Tkinter?
- How to set the font size of Entry widget in Tkinter?
- How to change the Entry Widget Value with a Scale in Tkinter?
- How to set focus on Entry widget in Tkinter?
- How to change the font and size of buttons and frame in tkinter?
- How to change the font and color on the UITextView in iOS?
- How to use the Entry widget in Tkinter?
- How to remove Ttk Notebook Tab Dashed Line? (tkinter)
- How to change a Tkinter widget's font style without knowing the widget's font family/size?
- How to change the color of a Tkinter rectangle on clicking?
- How to clear Text widget content while clicking on the Entry widget itself in Tkinter?
- How to change Tkinter label text on button press?
- How to disable an Entry widget in Tkinter?
- How to change the size of text on a label in Tkinter?
- How to connect a variable to the Tkinter Entry widget?