I am building a fairly complicated GUI in TKinter so naturally have been using the .grid function.
I have grouped some of my widgets into Frames to make them easier to handle, but for some reason when I use .grid with widgets in a frame, the sticky attribute does not seem to work - my widgets don't fill the whole frame.
Example:
f3 = tk.Frame(self, borderwidth=1, relief="ridge")
f3.grid(row=0, column=0, sticky="NS")
tk.Label(f3, text="Site List").grid(in_=f3, row=0, column=0)
self.sitelist = tk.Listbox(f3)
self.sitelist.grid(in_=f3, row=1, column=0, sticky="NS")
In the above code, the frame f3
fills the space in the 0,0 cell of my root widget, but the Listbox does not fill all the space in the Frame, even though I have asked it to be sticky "NS".
If put the Listbox in the root widget at 0,0 then it stretches and fills all the space fine. It just does not behave well if it is in the Frame.
Can anyone explain how to get around this?
I thought that using frames would simplify my layout, but it is not!!!
Cheers.
Chris
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…