Why does Tkinter frame resize when text box is added to it?

With this code, the window is 500 by 500, which is what I'm going for:

from tkinter import *
root = Tk()

frame = Frame(root, width=500, height=500)

frame.pack()
root.mainloop()

When I add a text box to the frame, though, it shrinks to just the size of the text box:

from tkinter import *
root = Tk()

frame = Frame(root, width=500, height=500)

text = Text(frame, width=10, height=2) # THESE TWO
text.pack()                            # LINES HERE

frame.pack()
root.mainloop()

Why does this happen, and how can I prevent it from happening?

6
задан Bryan Oakley 1 October 2010 в 20:08
поделиться