8

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.

petezurich
  • 9,280
  • 9
  • 43
  • 57
Skitzafreak
  • 1,797
  • 7
  • 32
  • 51

2 Answers2

15

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)
J...S
  • 5,079
  • 1
  • 20
  • 35
Efrain Vergara
  • 151
  • 1
  • 3
1

when you want to use columnspan you will need to make sure sticky W and E selected, similar for rowspan you will need N and S

Developer Sheldon
  • 2,140
  • 1
  • 11
  • 17