You would typically do this when you use a geometry manager (pack, place, or grid).

Using grid:

import tkinter as tk

root = tk.Tk()
for row, text in enumerate((
        "Hello", "short", "All the buttons are not the same size",
        "Options", "Test2", "ABC", "This button is so much larger")):
    button = tk.Button(root, text=text)
    button.grid(row=row, column=0, sticky="ew")

root.mainloop()

Using pack:

import tkinter as tk

root = tk.Tk()
for text in (
        "Hello", "short", "All the buttons are not the same size",
        "Options", "Test2", "ABC", "This button is so much larger"):
    button = tk.Button(root, text=text)
    button.pack(side="top", fill="x")

root.mainloop()
Answer from Bryan Oakley on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ how do i make the buttons be square in tkinter?
r/learnpython on Reddit: How do I make the buttons be square in Tkinter?
March 18, 2022 -

I tried to do it with padx and pady by setting them to the same value, not square.

I tried to do it with width and height parameters also setting them to the same value, it's still not square.

I am stuck, does anyone know why these methods are not working and which ones do?

Discussions

Tkinter: making buttons the same size?
on windows vista these buttons dont have the same size, the "/" shrinks a little. how do i make them the same size or prevent shrinking? a mac-user told me they look the same to him so maybe it doesnt shrink on macs but it does when using VISTA. i tried some .propagate and extend-stuff but... More on thecodingforums.com
๐ŸŒ thecodingforums.com
4
April 5, 2008
How do I change button size in Python? - Stack Overflow
I am doing a simple project in school and I need to make six different buttons to click on. The buttons must have different sizes, but I can't find how do do it. I have made the button by using: def More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to fit button's size in Tkinter? - Stack Overflow
I have been working with python for a week and with Tkinter even less, so sorry if my question will be typical. I want to write a simple GUI for an oscilloscope. And I have encountered a problem wi... More on stackoverflow.com
๐ŸŒ stackoverflow.com
python - How to get all the buttons to be automatically the same size depending on the largest one in tkinter using canvas? - Stack Overflow
I've updated the answer, better ... the same problem as yours. ... Is it better to redirect users who attempt to perform actions they can't yet... 65 How to create a self resizing grid of buttons in tkinter? ... Was the meaning of ... (ellipsis) for buttons and menus already defined in MS DOS? ... What tree is this, growing in cluster with alternate stems, bark with lenticils, bud like vibernums? ... Can you always find a continuum-sized subfamily ... More on stackoverflow.com
๐ŸŒ stackoverflow.com
๐ŸŒ
LinuxQuestions.org
linuxquestions.org โ€บ questions โ€บ programming-9 โ€บ tkinter-gui-how-to-make-btuttons-the-same-size-633138
Tkinter-GUI: how to make btuttons the same size?
Buttons shrink to fit the symbol/text u put on it. well i dont want that it looks ugly. how do i set the same size for all the buttons? i thought it
๐ŸŒ
Python
mail.python.org โ€บ pipermail โ€บ tkinter-discuss โ€บ 2008-April โ€บ 001383.html
[Tkinter-discuss] How to make all the buttons the same size?
May 4, 2008 - [code] #! /usr/bin/env python from Tkinter import * import tkMessageBox class GUIFramework(Frame): """This is the GUI""" def __init__(self,master=None): """Initialize yourself""" """Initialise the base class""" Frame.__init__(self,master) """Set the Window Title""" self.master.title("Calculator") """Display the main window" with a little bit of padding""" self.grid(padx=10,pady=10) self.CreateWidgets() def CreateWidgets(self): self.btnDisplay = Button(self, text="1", state=DISABLED) self.btnDisplay.grid(row=0, column=0, padx=5, pady=5) self.btnDisplay = Button(self, text="2", state=DISABLED) s
๐ŸŒ
The Coding Forums
thecodingforums.com โ€บ archive โ€บ archive โ€บ python
Tkinter: making buttons the same size? | Python | Coding Forums
April 5, 2008 - Click to expand... Add it to the Button widget, not to the grid method. mybtn = Button(..., width=1) Thanks, ... Click to expand... Please include enough from the post you are answering to make the context clear for someone who has not received the previous message.
๐ŸŒ
TutorialsPoint
tutorialspoint.com โ€บ how-do-i-change-button-size-in-python-tkinter
How do I change button size in Python Tkinter?
October 4, 2024 - Button(win, text="Button-1", height=3, width=10).pack() Button(win, text="Button-2", height=5, width=15).pack() Button(win, text="Button-3", height=10, width=20).pack() #Import the required libraries from tkinter import * #Create an instance of tkinter frame win= Tk() #Set the geometry of frame win.geometry("600x600") # make the window non-resizable win.resizable(False, False) Button(win, text="Button-1",height= 3, width=10).pack() Button(win, text="Button-2",height=5, width=15).pack() Button(win, text= "Button-3",height=10, width=20).pack() # start the main loop win.mainloop()
๐ŸŒ
Delft Stack
delftstack.com โ€บ home โ€บ howto โ€บ python tkinter โ€บ how to change the tkinter button size
How to Change the Tkinter Button Size | Delft Stack
February 5, 2025 - After the Button widget has been created, the configure method could set the width and/or height options to change the Button size. ... It sets the height and width of buttonExample1 to be 100. import tkinter as tk import tkinter.font as tkFont ...
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ watch
How To Resize Buttons in TTKBootstrap - Tkinter TTKBootstrap 4 - YouTube
In this video I'll show you how to resize buttons and give them different sized fonts, with ttkbootstrap and tkinter.To resize a button and it's font with tt...
Published ย  January 3, 2023
Top answer
1 of 2
5

If you want these widgets to be really perfectly aligned with one another, it's definitely better to align them on the same grid and use the sticky argument to make the buttons stretch to fill their cell:

import tkinter as tk

root = tk.Tk()

chLabel = tk.Label(root, text="Channel group")
channelButtons = tk.Frame(root, bg='yellow')
ch1Button = tk.Button(channelButtons, text="CH1 Settings")
ch1Button.pack(fill='x')
ch2Button = tk.Button(channelButtons, text="CH2 Settings")
ch2Button.pack(fill='x')
ch3Button = tk.Button(channelButtons, text="CH3 Settings")
ch3Button.pack(fill='x')
ch4Button = tk.Button(channelButtons, text="CH4 Settings")
ch4Button.pack(fill='x')

trigLabel = tk.Label(root, text="Trigger group")
trigButton = tk.Button(root, text="Trigger Settings")

horizLabel = tk.Label(root, text="Horizontal group")
horizButton = tk.Button(root, text="Horizontal settings")

# Align the labels and buttons in a 2-by-3 grid
chLabel.grid(row=0, column=0, pady=10)
trigLabel.grid(row=0, column=1, pady=10)
horizLabel.grid(row=0, column=2, pady=10)
channelButtons.grid(row=1, column=0, sticky='news')
trigButton.grid(row=1, column=1, sticky='news')
horizButton.grid(row=1, column=2, sticky='news')

root.mainloop()
2 of 2
2

The root of the problem is that you aren't taking advantage of the options available to pack and grid. For example, when you do .pack(side='left'), you are leaving it up to tkinter to decide how to vertically align the widget in the space allotted.

By default tkinter will center the items vertically. Since the native height of the various sections (channel group, trigger group, horizontal group) are slightly different, it prevents them from having the tops and/or bottoms perfectly aligned.

A simple fix is to use the "fill" option to have the widgets fill the space allocated to them. If you don't want them to fill the space allotted you can use the "anchor" option to have the widgets anchored to the top.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ dynamically-resize-buttons-when-resizing-a-window-using-tkinter
Dynamically Resize Buttons When Resizing a Window using Tkinter - GeeksforGeeks
September 4, 2021 - So the solution here is, make a dynamic button, which means the button size will change as per window size. Let's understand with step-by-step implementation: ... # Import module from tkinter import * # Create object root = Tk() # Adjust size ...
๐ŸŒ
Tcl Wiki
wiki.tcl-lang.org โ€บ page โ€บ tkinter.Button
tkinter.Button
In "active" state, the button is ... a non-default button, leaving enough space to draw the default button appearance. The "normal" and "active" states will result in buttons of the same size....
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 55034019 โ€บ python-with-tkinter-auto-resize-buttons-but-keeping-same-size
python with TkInter - Auto resize buttons but keeping same size - Stack Overflow
I'm working with python and TkInter. I need to place two buttons in a resizable screen that when the screen gets bigger, so do the buttons. I found how to do that in here. I also found how the w...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ [tkinter] why can't i create a square button?
r/learnpython on Reddit: [Tkinter] Why can't I create a square button?
July 11, 2018 -

Here are my codes:

from tkinter import *
window = Tk ()
window.title(" ")
window.geometry('600x600')

btn = Button(window, text ="X", bg = "white")
btn.config(height = 15, width = 15)
btn.grid(column = 0, row = 0)

window.mainloop()

I set the size of the button to be btn.config(height = 15, width = 15), which is supposed to be a square.

The window is a square but the button appears like this! The button is a rectangle! Besides, there is obviously something wrong when looking at the size ratio of the button to the window (which is window.geometry('600x600')) - the button should be very small (15x15 compared to 600x600)!

What's the problem? The window is a square but the button is a rectangle.

Anyone can run the codes and tell me what they see? Maybe it happens only to my PC?

๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ tkinter button size alignment issues
r/learnpython on Reddit: Tkinter button size alignment issues
July 28, 2024 -

Im following a Tkinter tutorial on Youtube. The button spacing, for whatever reason isnt aligning. The buttons in the turtorial all seam to align properly with the inputs however, my buttons do not dispite changing them. The "equals" button wont align with the others, on the right side. The "subtract" button also wont align with the column on the right side with the padx = 41 setting shown in the video. Havent addressed the other buttons as of yet because OCD is driving my nuts on the euals and subtract buttons!

This is my current progress through the code linky and this is the tutorial vid linky2 time stamp is 5:48

Any assistants is appreciated!

๐ŸŒ
DocStore
docstore.mik.ua โ€บ orelly โ€บ perl3 โ€บ tk โ€บ ch04_13.htm
Changing the Size of a Button (Mastering Perl/Tk)
Normally the size of the Button is automatically determined by the application and is dependent on the text string or image displayed in the Button. The width and height can be specified explicitly by using the -width and -height options: ยท The values specified for x and y vary depending on ...
Top answer
1 of 3
6

Regarding your initial question: the button does appear physically. The problem is, since it is so large, it is hard to distinguish from the rest of the window.

Now, you said that your ultimate goal is to change the size of a button. If so, then you are on the right track: you use the height and width options for this.

However, I would recommend that you make a few changes to your code:

  1. Don't make the button so huge. Even on a very big monitor, having a button be that size is way overkill.
  2. Don't make the window so huge. Nobody wants an application that takes up the entire screen.
  3. Use .grid instead of .place. Doing so will make it easier for you to place widgets where you want them.
  4. Set the height and width options when you make the button, not after it.
  5. There is no need to import sys here. Only import what you need.
  6. Don't import like this: from tkinter import *. Doing so dumps a whole bunch of names in the global namespace that can easily be overwritten.

Here is my version of your script:

import tkinter as tk

def mmWindow():
    mmWindow = tk.Tk()
    mmWindow.geometry('600x600')

mWindow = tk.Tk()
# You can set any size you want
mWindow.geometry('500x500+0+0')
mWindow.title('DMX512 Controller')

wtitle = tk.Label(mWindow, text="Pi DMX", fg='blue')
wtitle.grid(row=0, column=1)

# You can set any height and width you want
mmbutton = tk.Button(mWindow, height=5, width=20, text="Main Menu", command=mmWindow)
mmbutton.grid(row=1, column=1)

mWindow.mainloop()
2 of 3
1
import sys
from tkinter import *

def update_window_size():
    mmWindow.geometry('600x600')

mmWindow  = Tk()
mmWindow .geometry('1920x1080+0+0')
mmWindow .title('DMX512 Controller')

wtitle = Label(mmWindow, text="Pi DMX", fg='blue')
wtitle.place(relx=0.33, rely=0.0925925)

mmbutton = Button(mmWindow, text="Main Menu", command=update_window_size)
mmbutton.place(relw=0.104167, relh=0.185185, relx=0.104167, rely=0.185185)

mmWindow.mainloop()

I know this is late, but just want to add my method of how to solve the issue of how to make the button size change. I believe using place with relw and relh will be a better way to go. relw and relh & relx and rely will be fraction of the height and width of the parent widget. Therefore you do not need to worry about adjusting the size of both the wtitle and mmbutton.

If you want to change it's width and height from place then just put the code below on button command.

def update_button_size():
    mmbutton.place(width=20, height=20)

mmbutton = Button(mmWindow, text="Main Menu", command=update_button_size)
mmbutton.place(width=400, height=400, relx=0.104167, rely=0.185185)

If you want to change it's width and height from config then use code below.

def update_button_size():
    mmbutton.config(width=20, height=20)

mmbutton = Button(mmWindow, text="Main Menu", command=update_button_size)
mmbutton.place(relx=0.104167, rely=0.185185)
mmbutton.config(width=400, height=400)

From my understanding config width and height is different from place width and height.

๐ŸŒ
Tkinter
tkinter.com โ€บ how-to-resize-buttons-in-ttkbootstrap-tkinter-ttkbootstrap-4
How To Resize Buttons in TTKBootstrap โ€“ Tkinter TTKBootstrap 4 โ€“ TKinter.com
January 3, 2023 - from tkinter import * import ttkbootstrap as tb root = tb.Window(themename="superhero") #root = Tk() root.title("TTK Bootstrap!") root.iconbitmap('images/codemy.ico') root.geometry('500x350') # Style my_style = tb.Style() my_style.configure('success.Outline.TButton', font=("Helvetica", 18)) my_button = tb.Button(text="Hello World!", bootstyle="success", style="success.Outline.TButton", width=20) my_button.pack(pady=40) root.mainloop()