Python SDK: ux

The following UX elements are supported by the Python SDK:

  • Print
  • Progress Bars
  • Spinners

The spinner and progress bar APIs in ux are top-level functions: progress_bar_start, progress_bar_advance, progress_bar_stop, spinner_start, and spinner_stop.

ux.bold

ux.bold(text: str) -> str

Formats text as boldface for printing with ux.print or as a message in any of the other ux or prompt functions.

Formats correctly in the terminal and in Slack.

Example:

ux.italic

ux.italic(text: str) -> str

Formats text as italic for printing with ux.print or as a message in any of the other ux or prompt functions.

Formats correctly in the terminal and in Slack, but terminal support for italic text is limited.

Example:

ux.print

ux.print(text: str):

Displays text to the user. Locally, prints to the command-line.

Example:

Output:

ux.spinner_start

ux.start(text: str):

Starts a spinner accompanied with the given message.

ux.spinner_stop

ux.stop(text: Optional[str] = None):

Stops the currently running spinner, replacing the message with the given text.

Example:

ux.progress_bar_start

progress_bar_start(length: int, initial: int = 0, message: Optional[str] = None):

Creates and displays a progress bar, with length increments of which initial are already ready, and with an accompanying optional message.

ux.progress_bar_advance

progress_bar_advance(increment: int = 1):

Increments the value of a progress bar by increment, or by 1 increment if no argument is provided.

ux.progress_bar_stop

progress_bar_stop(message: Optional[str] = None):

Completes the progress bar, incrementing it to 100% and optionally replacing the message with the given one.

Example: