python Tkinter get() value from Entry Field

前端 未结 3 1184
感情败类
感情败类 2020-12-10 09:31

I have getting confused in getting the value from the Tkinter() Entry Field. I have this kind of code...

from Tkinter import*

def valueGET(val1, val2):
             


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-10 10:31

    The code call valueGET even before submit button is created. Then it pass the return value of the function to Button constructor as command argument.

    To register the function as callback, replace folloiwng line:

    submit = Button(frame, text="Enter", width=15, command=valueGET(E1.get(), E2.get())) 
    

    with:

    submit = Button(frame, text="Enter", width=15, command=lambda: valueGET(E1.get(), E2.get())) 
    

提交回复
热议问题