Simple easygui User Input (enterbox)

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:
import easygui
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.

3 Responses to “Simple easygui User Input (enterbox)”

  1. ShowMeDo Blog » Blog Archive » Simple easygui File Dialogs Says:

    [...] Did you know that you can have a file-open or -save dialog in just 2 lines of Python? Stephen Ferg’s excellent easygui module makes it possible. No other modules are needed, easygui is cross-platform.  See also the enterbox example. Two lines of code: [...]

  2. ShowMeDo Blog » Blog Archive » Simple easygui Yes/No Input (boolbox) Says:

    [...] Simple Yes/No queries give us a simple way of asking the user for confirmation. Stephen Ferg’s easygui makes this easy with the ynbox. No other modules are needed, easygui is cross-platform. This follows-on from the enterbox and fileopenbox examples. [...]

  3. Python Bytes - Today’s Top Blog Posts on Python - Powered by SocialRank Says:

    [...] ShowMeDo.com: Simple easygui User Input (enterbox) [...]

Leave a Reply

You must be logged in to post a comment.