0

I would like to add a hint value to my text box. It should look like this-

hint value

(like- "Enter your comments" in the picture, when there is nothing wroth on the field I want to be hint there)

my code-

  field = 'UserName'
  row = Frame(root)
  lab = Label(row, width=15, text=field, anchor='w')
  ent = Entry(row)
  row.pack(side=TOP, fill=X, padx=5, pady=5)
  lab.pack(side=LEFT)
  ent.pack(side=RIGHT, expand=YES, fill=X)

how can I do this?

Thanks.

cs95
  • 379,657
  • 97
  • 704
  • 746
shahar elbaz
  • 9
  • 1
  • 4

2 Answers2

1

It's simple you should add a default value for it.

  field = 'UserName'
  row = Frame(root)
  lab = Label(row, width=15, text=field, anchor='w')
  ent = Entry(row)


  ent.insert(0, 'Your default value here...')


  row.pack(side=TOP, fill=X, padx=5, pady=5)
  lab.pack(side=LEFT)
  ent.pack(side=RIGHT, expand=YES, fill=X)
0

So, as you must have realised by now, there is no placeholder/hint attribute. You can only emulate the feature by using default values and mouse click events.

if you want the default text to look like placeholder, make necessary styling adjustments. Eg: You can color the text with color: #b3b3b3;

I know its a hack, but this is the only way I can think of.

Arun Sethupat
  • 109
  • 1
  • 11