Skip to content Skip to sidebar Skip to footer

Issue With Placing Tkinter Widgets Within Frame

I've just started using Tkinter, and I'm having a very simple issue that is driving me insane. I'm trying to place a button within a label frame. It's a very simple task with many

Solution 1:

The value returned by pack() is None. So you are assigning lblframe to hold a value of None and therefore when you create the Button widget it has None passed as the parent. That causes its parent to be the application toplevel hence the packing you see (both widgets are packed into the same container). If you do the creation and packing separately it will work as you expect eg:

from tkinter import *

application = Tk()
lblframe = LabelFrame(application, width=300, height=300, text="Test", bd=10)
btn = Button(lblframe, text="Button 1")
lblframe.pack()
btn.pack()
application.mainloop()

Post a Comment for "Issue With Placing Tkinter Widgets Within Frame"