I'm currently developing my first python program, a booking system using tkinter. I have a customer account creation screen that uses a number of Entry boxes. When the Entry box is clicked the following key bind is called to clear the entry box of its instruction (ie. "enter name")
def entry_click(event):
if "enter" in event.widget.get():
event.widget.delete(0, "end")
event.widget.insert(0, "")
event.widget.configure(fg="white")
#example Entry fields
new_name = Entry(root)
new_name.insert(0, "enter name")
new_name.bind('', entry_click)
new_name.bind('', entry_focusout)
new_email = Entry(root)
new_email.insert(0, "enter email")
new_email.bind('', entry_click)
new_email.bind('', entry_focusout)
In a similar vein I'm looking for a way to create a universal event where the appropriate text for that unique entry field is returned to its initial state (ie. "enter first name" or "enter email") if the box is empty when clicked away from.
def entry_focusout():
if not event.widget.get():
event.widget.insert(fg="grey")
event.widget.insert(0, #[appropriate text here])
How would I be able to do this? Many thanks.
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)