- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
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 font size in ttk.Button?
Tkinter Ttk is a native library in Tkinter which is used to style the widgets in a Tkinter application. It provides a native GUI interface to all the widgets defined in the application.In order to style the widgets with ttk, we have to import it in the notebook using the command ‘from tkinter import ttk’.
For a particular application, we can change the font properties such as background color, foreground color, font size, font-family, and font style by defining an instance of ttk style object. After initializing the ttk object, we can configure(options) each widget defined in an application.
Example
In this example, we will create a button that can be customized after defining the style object.
#Import the required Libraries from tkinter import * from tkinter import ttk #Create an instance of tkinter frame win = Tk() #Set the geometry of tkinter frame win.geometry("750x270") #Create an instance of Style Object style = ttk.Style() #Create ttk buttons small_button = ttk.Button(win, text="small button", style="small.TButton") small_button.pack(pady=20) big_button = ttk.Button(win, text="big button", style="big.TButton") big_button.pack() #Configure the properties of the Buttons style.configure('big.TButton', font=(None, 20), foreground="blue4") style.configure('small.TButton', font=(None, 7)) win.mainloop()
Output
Running the above code will display a window that will contain two buttons of different sizes and properties.
In the given output, there are two ttk buttons which are having different properties such as font size and color. We can modify the font size by updating the values in the configuration.
- Related Articles
- How to change the color of ttk button in Tkinter?
- Change the font size of a button with CSS
- How to change font size in HTML?
- How to change the font size of textView in android?
- How to change xticks font size in a matplotlib plot?
- How to change PowerShell ISE font Size using command?
- How to change font size with HTML in Java Swing JEditorPane?
- How to change the font size of scientific notation in Matplotlib?
- How to change the font size of Text using FabricJS?
- How can I change the font family and font size with jQuery?
- Changing ttk Button Height in Python
- How do I change button size in Python Tkinter?
- How to change the font size of legend in base R plot?
- How to change the font size of a text using JavaScript?
- How to change the font size of a Textbox using FabricJS?
