Changing ttk Button Height in Python

PythonTkinterServer Side ProgrammingProgramming

Ttk adds styles to the tkinter’s standard widget which can be configured through different properties and functions. We can change the height of the ttk button by using the grid(options) method. This method contains various attributes and properties with some different options. If we want to resize the ttk button, we can specify the value of internal padding such as ipadx and ipady.


Let us understand it with an example,

#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
#Create a button using the ttk themed widget
button = ttk.Button(win, text = "Button")
button.grid(ipadx=10, ipady=30 )


In the above code, we have added internal padding to the button widget. Now, run the program to display the output,

Published on 21-Apr-2021 10:58:39