Frame and text widgets are not displayed.

from tkinter import* root=Tk() fra=Frame(root,height=500,width=500,bg='lightgreen') fra.pack() tex1=Entry(fra,width=20) tex1.pack() tex2=Entry(fra,width=20) tex2.pack() root.mainloop() 
  • What should this code demonstrate? - Fomina Catherine
  • Mistaken wrong code - A.Kross
  • brackets in fra.pack put - Twiss

1 answer 1

Add fra.pack_propagate(False) so that the frame does not shrink to the size of the text fields:

 from tkinter import* root=Tk() fra=Frame(root,height=500,width=500,bg='lightgreen') fra.pack_propagate(False) fra.pack() tex1=Entry(fra,width=20) tex1.pack() tex2=Entry(fra,width=20) tex2.pack() root.mainloop() 

And by the way, lightgreen is light green, not blue.

Screenshot