To set the width and height of a Tkinter button in Python, you can use the width
and height
options. Here's an example code snippet to create a button with 40 pixels width and 30 pixels height:
main.py133 chars9 lines
In this code, we first import the tkinter
module and create a new Tk
object by calling its constructor. Then, we create a new Button
widget and pass it the root
window as its parent, as well as specify the text to display on the button. We set the width
and height
options to 40 and 30, respectively, and call the pack()
method to add the button to the parent window. Finally, we start the main event loop by calling the mainloop()
method of the root
window.
gistlibby LogSnag