- 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 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.
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()
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.
- How can I change the font family and font size with jQuery?
- How to change the font size of textView in android?
- How to change font size in HTML?
- How to change font size in ttk.Button?
- How to set the font size of Entry widget in Tkinter?
- How to change the font on ttk.Entry in Tkinter?
- How to change the font size of scientific notation in Matplotlib?
- How to change the orientation and font size of x-axis labels using ggplot2 in R?
- How to Change Tkinter Frame Title?
- How to change a Tkinter widget's font style without knowing the widget's font family/size?
- How to change the font size of legend in base R plot?
- How do I change the font size of ticks of matplotlib.pyplot.colorbar.ColorbarBase?
- How to set the font size of a Tkinter Canvas text item?
- Change the font size of a button with CSS