ttk button span multiple columns

Skitzafreak picture Skitzafreak · Jun 20, 2017 · Viewed 11.4k times · Source

I am trying to make a TTK Button that spans multiple columns within a frame. Basically I have two rows of buttons, and I want the last button underneath both rows, to span the width of both rows.

However I am not sure how to accomplish this. This is the code I have on the button:

btnOff = ttk.Button(self, text = "OFF", command = tc.Off).
                    grid(column = 1, row = 10, columnspan = 2, rowspan = 2)

I have tried increasing the column width, but it doesn't seem to help. In fact, even when I try to just set it up normally it is smaller than the other buttons in the rows above it, even though all those buttons have the same grid code as what I posted above.

Answer

Efrain Vergara picture Efrain Vergara · Oct 7, 2017

Example expand last two columns. Row 10 and columns 1 and 2

python 2

import Tkinker as tk

python 3

import tkinter as tk
btnOff = ttk.Button(self, text = "OFF", command = tc.Off).
                grid(column = 1, row = 10, columnspan = 2, sticky = tk.W+tk.E)