I want to make three buttons in a row, but the width of the widgets isnt the same factor as the tkinter window (wanted to have each button 1/3 width of the tkinter windows width(400px).
Here is the code:
from tkinter import *
window = Tk()
window.geometry("400x400")
window.update()
print(window.winfo_width())
button = Button(window, width=window.winfo_width() // 3)
button.grid(row=0, column=0)
button = Button(window, width=window.winfo_width() // 3)
button.grid(row=0, column=1)
button = Button(window, width=window.winfo_width() // 3)
button.grid(row=0, column=2)
window.mainloop()
How can i solve this? Thanks in advance.
Edit:
Thanks everyone i have figured it out. If someone else has the same problem, this site might also help.
width=use.grid(..., sticky='ew')and allow the Columns to grow usingwindow.grid(0, weight=1). Do so for all Column. - stovfl