- 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
How to change the font and size of buttons and frame in tkinter?
Tkinter Button Widgets are a general way to provide Event Handling in a variety of applications. Sometimes, we may need to style the buttons which are defined in an application. In order to add styling in the button widgets, first create an instance of Button widget using a variable. Then, add some property like fontfamily, font-size, padding, etc. into it. The most general way to resize the button is by resizing the text in it.
Example
In this example, we have created a button that can be resized by changing the value in the 'font' property.
#Import tkinter library from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the Geometry win.geometry("750x250") def click_to_close(): win.destroy() #Create a Button button= Button(win, text= "Click to Close", font= ('Helvetica 20 bold italic'), command=click_to_close) button.pack(pady=20) win.mainloop()
Output
Running the given code will generate a button with some text in it which can be resized by changing the value of the font-size.
- Related Articles
- How can I change the font family and font size with jQuery?
- How to set the font size of Entry widget in Tkinter?
- How to change font size in HTML?
- How to change font size in ttk.Button?
- How to change the font on ttk.Entry in Tkinter?
- How to change the font size of textView in android?
- How to change a Tkinter widget's font style without knowing the widget's font family/size?
- How to change the font size using CSS?
- Change the font / size of row and column headings in Excel
- How to change the font size of scientific notation in Matplotlib?
- How to Change Tkinter Frame Title?
- How to change the font size of Text using FabricJS?
- How to change chart axis labels' font color and size in Excel?
- How to change the orientation and font size of x-axis labels using ggplot2 in R?
- How to set the font size of a Tkinter Canvas text item?

Advertisements