Reputation: 21
I'm trying to bind the Enter Key
to the Enter Button
, but if i try it with "event" the function dosn't work, if i do it without the key don't works.
Below are the pieces of the code for this problem.
def enterbutton():
ip01 = input = date_write.get()
ip02 = input = text_write.get()
ip03 = input = total_write.get()
output_label = Label (chart_frame, text=ip01 + " " + ip02 + " " + ip03 + " wurde eingetragen").place (relx=0.15, rely=0.85, anchor=NW)
chart_frame.after (0, clearfield)
chart_frame.after (5000, output_label.destroy)
def clearfield():
text_write.delete(0, "end"),
date_write.delete(0, "end"),
total_write.delete(0, "end")
return None
#Input Button
enter_button = Button (input_frame, text="Enter", command=enterbutton)
enter_button.place (height=20, width=50, relx=0.05, rely=0.7)
#Eintrag-Eingabe
text_write = Entry (input_frame)
text_write.place (height=20, relwidth=0.9, relx=0.05, rely=0.20, anchor=NW)
te_writeL = Label (input_frame, text="Eintrag:")
te_writeL.place (height=20, width=50, relx=0.05, rely=0.05)
root.bind ("<Return>", enterbutton)
Upvotes: 2
Views: 31
Reputation: 693
When you enter a command in python that had been defined it needs brackets after it for example
enter_button = Button (input_frame, text="Enter", command=enterbutton())
I added brackets at the end
Upvotes: 1