I am making my first GUI application and I ran into a dumb problem. Resizing the main window does not resize its contents and leaves a blank space. I read TKDocs and they only say that you should use sticky weight and column / row attributes, but I really don't understand how they work. Here is my code (only parts of the coverage of widgets, if you think that the problem is not here, I will lay out the rest):
from tkinter import * from tkinter import ttk root = Tk() mainframe = ttk.Frame(root, padding="3 3 12 12") mainframe.grid(column=0, row=0, sticky=(N, W, E, S)) mainframe.columnconfigure(0, weight=1) mainframe.rowconfigure(0, weight=1) player1 = StringVar() player2 = StringVar() player1.set('Player 1') player2.set('Player 1') timer=StringVar() running=BooleanVar() running.set(0) settimer = ttk.Entry(mainframe, width=7, textvariable=timer) settimer.grid(column=2, row=1, sticky=(N, S)) ttk.Button(mainframe, text="Start", command=start).grid(column=2, row=2, sticky=(N, S)) ttk.Label(mainframe, textvariable=player1, font=TimeFont).grid(column=1, row=3, sticky=(W, S)) ttk.Label(mainframe, textvariable=player2, font=TimeFont).grid(column=3, row=3, sticky=(E, S)) for child in mainframe.winfo_children(): child.grid_configure(padx=80, pady=10) root.mainloop()
Thank you for your time!
Dunno source share