I have a following peice of code where I want query button to disappear when entry box is empty. But that is not happening.When I tried to print the entry value on pressing any key, it shows the last value, not the current value.
eg. if "Test" is previous value in pin, than on hitting backspace pin.get()
shows Test instead of "Tes". I am new to python and Tkinter, so don't know what silly thing I am doing.
def send_button ():
print pin.get()
if pin.get() == "":
print "in if"
query.place_forget()
else:
query.place(relx=0.0, rely=0.75, relwidth=0.2, relheight=0.15)
return TRUE
#Entry box
pin = StringVar()
ent1 = Entry(top, textvariable = pin, validate = 'key', vcmd = send_button)
#Query button
query = Button (top, command = get_temp, text = 'Query')
top.mainloop()