I would like to have an entry widget with some default text in it, where the text contained in the entry widget is automatically “highlighted” (in the same way as when you drag your mouse over text), such that if you want to edit the entry you can just start typing and it will replace the text rather than requiring you to manually highlight and delete the default text, as many website do.
Here’s some example code:
from tkinter import *
root = Tk()
def myClick():
hello = "Hello " + my_entry.get()
my_label.configure(text=hello)
my_entry = Entry(root)
my_entry.insert(END, "Enter your name here.")
my_entry.pack()
my_button = Button(root, text="Click Me!", command=myClick)
my_button.pack()
my_label = Label(root, text="")
my_label.pack()
root.mainloop()
I’ve tried searching about this in every way I can think of, but it’s hard to find. Thank you in advance for any help.
Roland Deschain is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.