0

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

2 Answers2

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