Following on from the fileopenbox example I’ll show you how to replace raw_input with an input-dialog in 2 lines of Python, using Stephen Ferg’s easygui module. No other modules are needed, easygui is cross-platform.
Text-input box with a default string:
result = easygui.enterbox(message="Enter your name", title="Name query", argDefaultText="Ian Ozsvald")
Anything the user types in is returned as a string, if the user hits Cancel then None is returned.
The resulting dialog looks like this on Windows:
Related: easygui has an integerbox just for numerical input.
To see easygui’s fileopenbox, filesavebox, choicebox, enterbox and ynbox in action and learn how to write a Python program from scratch, visit: Python 101 – easygui and csv.If you enjoyed this post, make sure you subscribe to my RSS feed!