JesseM
JesseM

Reputation: 1

Python / Tkinter grid sticky not filling vertical space

I'm trying to create a grid of buttons. The text within these buttons will change, so I want to buttons to be large - filling the borders of each grid element. The code below is a simplified version which illustrates the issue. The buttons mostly fill the horizontal space, but do not fill the vertical space (unless multiple lines of text are added as a button label).

from Tkinter import *
root = Tk()
buttons = {}
for y in range(3):
    root.rowconfigure(y, minsize=60)
for x in range(3):
    root.columnconfigure(x, minsize=60)
    for y in range(3):
        n = 3 * x + y
        buttons[n] = Button(root).grid(column=x, row=y, sticky=W + E + N + S)
root.mainloop()

This is what this yields for me:

tkinter sample window

Upvotes: 0

Views: 575

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 385800

Buttons on OSX really want to look like OSX buttons, and won't expand the way you want. This is one of the pitfalls of using native widgets.

Upvotes: 3

Related Questions