Reputation: 180
I want to know how can I place this button across 3 columns :
container.grid(columnspan=3, rowspan=5)
button_result = ttk.Button(container, text="Result").grid(column=(1,2,3), row=5)
I can only place it on column 1. What if I want to make it fill the space across column 1, 2 and 3 on row 5 ?
I didn't find the answer yet, still looking for it.
Thanks !
Upvotes: 1
Views: 2912
Reputation: 41
By adding parameter columnspan
you can "merge" multiple columns. Output will be centered button in merged columns. And by adding sticky
parameter you can expand button to sides.
columnspan=3
- merge 3 columns (starting with selected)sticky="we"
- expand button to the left and right sides (west, east)e.g.
from tkinter import Label, Button, Tk
app = Tk()
l1 = Label(text="text")
l1.grid(row=0, column=0, padx=10)
l2 = Label(text="text")
l2.grid(row=0, column=1, padx=10)
l3 = Label(text="text")
l3.grid(row=0, column=2, padx=10)
btn = Button(text="Check")
btn.grid(row=1, column=0, columnspan=3, sticky="we")
app.mainloop()
Check this.
Upvotes: 3