wizard.prompt

Interface compatible with PromptInterface for doing non-ncurses interaction.

By convention, the last line of a text parameter should be a short value with a trailing colon so that we can prompt a user for a value immediately after it.

Functions

wizard.prompt.make(prompt, non_interactive)

Makes a dialog.Dialog compatible class based on configuration.

Interfaces

class wizard.prompt.PromptInterface
infobox(text, **kwargs)

Gives the user a non-blocking message; useful if you are about to do an operation that will take some time.

inputbox(text, init='', **kwargs)

Request a free-form, single line of text from the user. Prompt the user using text; and init is the initial value filling the field; not all implementations support editing init. Returns the typed string.

menu(text, choices=[], **kwargs)

Request a selection from a number of choices from the user. Prompt the user using text; choices is a list of tuples of form (value to return, description), where value to return is the value that this function will return.

msgbox(text, **kwargs)

Gives the user a message that they must dismiss before proceeding.

passwordbox(text, **kwargs)

Securely requests a password from the user. Prompts the user using text; return value is the password.

Classes

class wizard.prompt.Dialog

Bases: wizard.prompt.PromptInterface

Ncurses interface using dialog.

class wizard.prompt.Prompt

Bases: wizard.prompt.PromptInterface

Simple stdin/stdout prompt object.

class wizard.prompt.FailPrompt

Bases: wizard.prompt.PromptInterface

Prompt that doesn’t actually ask the user; just fails with an error message.

Utility functions

wizard.prompt.fill(text, width=60, **kwargs)

Convenience wrapper for textwrap.fill() that preserves paragraphs.

wizard.prompt.guess_dimensions(text, width=60)

Guesses the dimensions that any given piece of text will need to display on terminal, given some width.

wizard.prompt.join_or(items)

Joins a list of disjunctions into a human readable sentence.

>>> join_or(['foo'])
'foo'
>>> join_or(['foo', 'bar', 'baz'])
'foo, bar or baz'
wizard.prompt.dialog_wrap(f)

Convenience decorator that automatically:

  1. Removes already handled keyword arguments,
  2. Configures the dimensions of the dialog box, and
  3. Handles the different ext possibilities of dialog.
wizard.prompt.prompt_wrap(f)

Convenience decorator that handles end-of-document and interrupts.

Exceptions

exception wizard.prompt.Error

Base error class.

exception wizard.prompt.MissingRequiredParam(cmdopt)

Bases: wizard.prompt.Error

Non-interactive, but we needed more info.

exception wizard.prompt.UserCancel

Bases: wizard.prompt.Error

User canceled the input process.

exception wizard.prompt.DialogError(exit)

Bases: wizard.prompt.Error

Dialog returned a mysterious error.

exception wizard.prompt.UnsupportedTerminal

Bases: wizard.prompt.Error

It doesn’t look like we support this terminal. Internal error.

Table Of Contents

Previous topic

wizard.plugin

Next topic

wizard.resolve

This Page