Is Placeholder in a tkinter entry field is possible. I saw it is possible using Objects or classes. But don't know actually how to do that
Asked
Active
Viewed 298 times
0
-
see https://stackoverflow.com/questions/27820178/how-to-add-placeholder-to-an-entry-in-tkinter – coderoftheday Dec 04 '20 at 14:33
2 Answers
2
Use .insert()
to add default value place holder
import tkinter as tk
win = tk.Tk()
e = Entry(win)
e.insert(0, 'Placeholder')
e.pack()
win.mainloop()

Wasif
- 14,755
- 3
- 14
- 34
1
You could use a StringVar
.
variable = tkinter.StringVar(root, “Spam”)
entry = tkinter.Entry(root, textvariable=variable)
#Set it to something else:
variable.set(“Bacon”)

Jacob Lee
- 4,405
- 2
- 16
- 37