Reputation: 129
When I run this code:
from tkinter import *
root = Tk()
fr = Frame(root, width=50, height=50).pack()
b = Button(fr, text='Click').pack()
root.mainloop()
button 'b' is outside the frame 'fr', acting as if i wrote root
instead of fr
in b = Button(fr, ...
.
Upvotes: 1
Views: 130
Reputation: 238877
You should execute pack on the object returned from Frame and Button.
fr = Frame(root, width=50, height=50)
fr.pack()
b = Button(fr, text='Click')
b.pack()
Otherwise, your fr and b are None, i.e. they take values returned by pack()
which is None.
Upvotes: 3