The frame size is entered into the text boxes and upon pressing the space bar the frame size changes. It is not possible to associate the input numbers with the frame size change. And for some reason, the frame color is not specified.

from tkinter import* root=Tk() def bar0(): tex1.get()=fra['height'] def bar1(): tex2.get()=fra['width'] 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() tex1.bind('<space>',bar0) tex2.bind('<space>',bar1) 

    1 answer 1

     from tkinter import* def bar0(e): fra['height'] = tex1.get() def bar1(e): fra['width'] = tex2.get() root=Tk() fra=Frame(root,height=500,width=500,bg='lightgreen') fra.pack() fra.pack_propagate(False) tex1=Entry(fra,width=20) tex1.pack() tex2=Entry(fra,width=20) tex2.pack() tex1.bind('<space>',bar0) tex2.bind('<space>',bar1) root.mainloop() 
    1. To begin with, you have the usual syntax error. For some reason, do you assign the functions of reading the text from Entry size of the widget fra
    2. When declaring a bind function, you must pass the event parameter to the function you are calling. Or you can use lambda e: bar0() so that in your case it would not be necessary to set the function argument
    3. For resizing the widget that is packaged by the pack function, there is a .pack_propagate(False) function to set the element to a fixed size. My answer to the question you have already asked

    enter image description here