1

I do not know how to ask a user for input giving him a hint at the same time.

When I use raw_input("some description") a small window pops up and the user must enter something, as the input is completely empty. How to achieve the same, but with something already written to the input box (a hint for the user, which he/she could accept or simply change it)?

Rob Hruska
  • 118,520
  • 32
  • 167
  • 192
user1703589
  • 41
  • 1
  • 5

1 Answers1

0

This has been answered before:

https://stackoverflow.com/a/2533142/1217949

The standard library functions input() and raw_input() don't have this functionality. If you're using Linux you can use the readline module to define an input function that uses a prefill value and advanced line editing:

def rlinput(prompt, prefill=''):
   readline.set_startup_hook(lambda: readline.insert_text(prefill))
   try:
      return raw_input(prompt)
   finally:
      readline.set_startup_hook()
Community
  • 1
  • 1
sonium
  • 918
  • 1
  • 11
  • 25
  • sonium - thanks, but unfortunately i am using windows :/ so it looks like there is no solution for the problem, when i want to do this without console (i.e. with a window poping out)? – user1703589 Mar 22 '13 at 13:39