- 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 do I change button size in Python Tkinter?
Tkinter Button widgets are used to create buttons that are necessary for an application. We can also add an event Object in the Button constructor and trigger it to perform some operation.
In order to customize the Button size, we can use the width and height property of the button widget.
Example
In this example, we will create some buttons with different sizes,
#Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x250") win.resizable(False, False) Button(win, text="Button-1",height= 5, width=10).pack() Button(win, text="Button-2",height=8, width=15).pack() Button(win, text= "Button-3",height=10, width=30).pack() win.mainloop()
Output
Running the above code will display a window containing buttons of different sizes.
Advertisements