

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 set font for Text in Tkinter?
Tkinter has many inbuilt methods and functions which are used to provide different features in the widgets. We can customize the font-property of text widget in a tkinter application using the font(‘font-family’,font-size, ‘style’) attribute. The tuple can be declared inside the Text constructor.
Example
Let us have a look at the following example where we will create a text widget with a customized font property. #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") #Define a text widget with font-property text= Text(win, height=15, font=('Times New Roman',17,'bold')) text.insert(INSERT, "Hey Folks!, Welcome to TutorialsPoint!") text.pack() win.mainloop()
Output
Running the above code will display a window that contains a text widget. The text written inside the text widget can be customized using the font property.
- Related Questions & Answers
- How to set font for text in JTextPane with Java?
- How to set the font size of a Tkinter Canvas text item?
- How to set the font family for text with JavaScript?
- How to set text font family in HTML?
- How to set a particular font for a button text in Android?
- How to set default text for a Tkinter Entry widget?
- How to set font to text node in JavaFX?
- How do we set text font in HTML?
- How to set font face, style, size and color for JTextPane text in Java
- How to set a particular font for a button text in Android using Kotlin?
- How to set the font size of Entry widget in Tkinter?
- How to set justification on Tkinter Text box?
- How to set the font size of text with JavaScript?
- How to set focus for Tkinter widget?
- How to change text font for JLabel with HTML in Java?
Advertisements