Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > UI (User Interfaces)

    qanda 0.1

    Download button

    No screenshots available
    Downloads: 165  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Paul-Michael Agapow | More programs
    MIT/X Consortium Lic... / FREE
    July 18th, 2011, 08:16 GMT
    ROOT / Programming / UI (User Interfaces)

     Read user reviews (0)  Refer to a friend  Subscribe

    qanda description

    Simple text prompts and validation for user input

    Interactive command-line programs need to query users for information, be it text, choices from a list, or simple yes-or-no answers.

    qanda is a Python module of simple functions to prompt users for such information, allowing validation and cleanup of answers, default responses, consistent formatting and presentation of help text, hints and choices.

    qandais not a replacement for textual interfaces like curses and urwid, but intended solely for simple console scripts with user input is required.

    Installation

    The simplest way to install qanda is via easy_install or an equivalent program:

    easy_install qanda


    Alternatively the tarball can be downloaded, unpacked and setup.py run:

    tar zxvf qanda.tgz
    cd qanda
    python set.py install


    qanda has no requisites and should work with just about any version of Python.

    Using qanda

    Examples

    >>> from qanda import prompt
    >>> prompt.string ("What is your name")
    What is your name: Foo
    >>> fname = prompt.string ("Your friends name is",
     help="I need to know your friends name as well before I talk to you.",
     hints="first name",
     default='Bar',
     )

    I need to know your friends name as well before I talk to you.
    Your friends name is (first name) [Bar]:
    >>> print fname
    Bar
    >>> years = prompt.integer ("And what is your age", min=1, max=100)
    And what is your age: 101
    A problem: 101 is higher than 100. Try again ...
    And what is your age: 28


    Central concepts

    qanda packages all question-asking methods in a Session class. This allows the appearance and functioning of all these methods to be handled consistently and modified centrally. However, you don't necessarily have to create a Session to use it - there's pre-existing Session in the variable called prompt:

    >>> from qanda import Session
    >>> s = Session()
    >>> from qanda import prompt
    >>> type (prompt)
    < class 'qanda.session.Session' >


    The question methods are named after the type of data they elicit:

    >>> print type(prompt.integer ("Pick a number"))
    Pick a number: 2
    < type 'int' >
    >>> print type(prompt.string ("Pick a name"))
    Pick a name: Bob
    < type 'string' >


    Many of the question methods with accept a list of "converters", each of which is used to sucessively transform or validate user input. If input fails validation, the question is posed again. qanda supplies a number of basic validators:

    ToInt, ToFloat
     Convert inputs to other types
    Regex
     nly allow values that match a certain pattern
    Range
     Check that input falls within given bounds
    Length
     Check that input length falls within given bounds
    Synonyms
     Map values to other values
    Vocab
     Ensure values fall within a fixed set


    Product's homepage

    Requirements:

    · Python

      


    TAGS:

    answers validation | user input | textual interface | answers | validation | cleanup

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM