# pyanaconda.ui.tui.simpleline package

## Submodules

## pyanaconda.ui.tui.simpleline.base module

class `pyanaconda.ui.tui.simpleline.base.``App`(title, yes_or_no_question=None, width=80, queue_instance=None, quit_message=None)

  Bases: `object`

  This is the main class for TUI screen handling. It is responsible for mainloop control and keeping track of the screen stack.

  Screens are organized in stack structure so it is possible to return to caller when dialog or sub-screen closes.

  It supports four window transitions: - show new screen replacing the current one (linear progression) - show new screen keeping the current one in stack (hub & spoke) - show new screen and wait for it to end (dialog) - close current window and return to the next one in stack

  Parameters: | title (str) – application title for whenever we need to display app name yes_or_no_question (class UIScreen accepting additional message arg) – UIScreen object class used for Quit dialog width (int) – screen width for rendering purposes

  `NOP` = None
  `START_MAINLOOP` = True
  `STOP_MAINLOOP` = False
  `close_screen`(scr=None)

    Close the currently displayed screen and exit it’s main loop if necessary. Next screen from the stack is then displayed.

    Parameters: | scr (UIScreen instance) – if an UIScreen instance is passed it is checked to be the screen we are trying to close.

  `header`
  `input`(args, key)

    Method called internally to process unhandled input key presses. Also handles the main quit and close commands.

    Parameters: | args (anything) – optional argument passed from switch_screen calls key (str) – the string entered by user
    Returns: | True if key was processed, False if it was not recognized
    Return type: | True|False

  `process_events`(return_at=None)

    This method processes incoming async messages and returns when a specific message is encountered or when the queue_instance is empty.

    If return_at message was specified, the received message is returned.

    If the message does not fit return_at, but handlers are defined then it processes all handlers for this message

  `raw_input`(prompt, hidden=False)

    This method reads one input from user. Its basic form has only one line, but we might need to override it for more complex apps or testing.

  `redraw`()

    Set the redraw flag so the screen is refreshed as soon as possible.

  `register_event_handler`(event, callback, data=None)

    This method registers a callback which will be called when message “event” is encountered during process_events.

    The callback has to accept two arguments:
      - the received message in the form of (type, [arguments])
      - the data registered with the handler

    Parameters: | event (number|string) – the id of the event we want to react on callback (func(event_message, data)) – the callback function data (anything) – optional data to pass to callback

  `run`()

    This methods starts the application. Do not use self.mainloop() directly as run() handles all the required exceptions needed to keep nested mainloops working.

  `schedule_screen`(ui, args=None)

    Add screen to the bottom of the stack. This is mostly usefull at the beginning to prepare the first screen hierarchy to display.

    Parameters: | ui (UIScreen instance) – screen to show args (anything) – optional argument, please see switch_screen for details

  `switch_screen`(ui, args=None)

    Schedules a screen to replace the current one.

    Parameters: | ui (instance of UIScreen) – screen to show args (anything) – optional argument to pass to ui’s refresh method (can be used to select what item should be displayed or so)

  `switch_screen_modal`(ui, args=None)

    Starts a new screen right away, so the caller can collect data back. When the new screen is closed, the caller is redisplayed.

    This method does not return until the new screen is closed.

    Parameters: | ui (UIScreen instance) – screen to show args (anything) – optional argument, please see switch_screen for details

  `switch_screen_with_return`(ui, args=None)
    Schedules a screen to show, but keeps the current one in stack
      to return to, when the new one is closed.

    Parameters: | ui (UIScreen instance) – screen to show args (anything) – optional argument, please see switch_screen for details

  `width`

    Return the total width of screen space we have available.

class `pyanaconda.ui.tui.simpleline.base.``UIScreen`(app, screen_height=25)

  Bases: `object`

  Base class representing one TUI Screen. Shares some API with anaconda’s GUI to make it easy for devs to create similar UI with the familiar API.

  Parameters: | app (instance of class App) – reference to application main class screen_height (int) – height of the screen (useful for printing long widgets)

  `app`

    The reference to this Screen’s assigned App instance.

  `close`()

    Close the current screen.

  `hide`()

    This does nothing in TUI, it is here to make API similar.

  `input`(args, key)

    Method called to process input. If the input is not handled here, return it.

    Parameters: | key (str) – input string to process args (anything) – optional argument passed from switch_screen calls
    Returns: | return True or INPUT_PROCESSED (None) if key was handled, INPUT_DISCARDED (False) if the screen should not process input on the App and key if you want it to.
    Return type: | True|False|None|str

  `prompt`(args=None)

    Return the text to be shown as prompt or handle the prompt and return None.

    Parameters: | args (anything) – optional argument passed from switch_screen calls
    Returns: | returns text to be shown next to the prompt for input or None to skip further input processing
    Return type: | str|None

  `refresh`(args=None)

    Method which prepares the content desired on the screen to self._window.

    Parameters: | args (anything) – optional argument passed from switch_screen calls
    Returns: | has to return True if input processing is requested, otherwise the screen will get printed and the main loop will continue
    Return type: | True|False

  `setup`(environment)

    Do additional setup right before this screen is used.

    Parameters: | environment (either FIRSTBOOT_ENVIRON or ANACONDA_ENVIRON) – environment (see pyanaconda.constants) the UI is running in
    Returns: | whether this screen should be scheduled or not
    Return type: | bool

  `show`()

    Prepares all elements of self._window for output and then prints them on the screen.

  `show_all`()

    Prepares all elements of self._window for output and then prints them on the screen.

  `title` = 'Screen..'

class `pyanaconda.ui.tui.simpleline.base.``Widget`(max_width=None, default=None)

  Bases: `object`

  Initializes base Widgets buffer.

  Parameters: | max_width (int) – server as a hint about screen size to write method with default arguments default (string) – string containing the default content to fill the buffer with

  `clear`()

    Clears this widgets buffer and resets cursor.

  `content`

    This has to return list (rows) of lists (columns) with one character elements.

  `cursor`
  `draw`(w, row=None, col=None, block=False)

    This method copies w widget’s content to this widget’s buffer at row, col position.

    Parameters: | w (class Widget) – widget to take content from row (int) – row number to start at (default is at the cursor position) col (int) – column number to start at (default is at the cursor position) block (boolean) – when printing newline, start at column col (True) or at column 0 (False)

  `get_lines`()

    Get lines to write out in order to show this widget.

    Returns: | lines representing this widget
    Return type: | list(str)

  `height`

    The current height of the internal buffer.

  `render`(width)

    This method has to redraw the widget’s self._buffer.

    Parameters: | width (int) – the width of buffer requested by the caller

    This method will commonly call render of child widgets and then draw and write methods to copy their contents to self._buffer

  `setend`()

    Sets the cursor to first column in new line at the end.

  `setxy`(row, col)

    Sets cursor position.

    Parameters: | row (int) – row id, starts with 0 at the top of the screen col (int) – column id, starts with 0 on the left side of the screen

  `width`

    The current width of the internal buffer (id of the first empty column).

  `write`(text, row=None, col=None, width=None, block=False)

    This method emulates typing machine writing to this widget’s buffer.

    Parameters: | text (str) – text to type row (int) – row number to start at (default is at the cursor position) col (int) – column number to start at (default is at the cursor position) width (int) – wrap at “col” + “width” column (default is at self._max_width) block (boolean) – when printing newline, start at column col (True) or at column 0 (False)

## pyanaconda.ui.tui.simpleline.widgets module

class `pyanaconda.ui.tui.simpleline.widgets.``TextWidget`(text)

  Bases: `pyanaconda.ui.tui.simpleline.base.Widget`

  Class to handle wrapped text output.

  Parameters: | text (str) – text to format

  `render`(width)

    Renders the text widget limited to width number of columns (wraps to the next line when the text is longer).

    Parameters: | width (int) – maximum width allocated to the string

    :raises

class `pyanaconda.ui.tui.simpleline.widgets.``ColumnWidget`(columns, spacing=0)

  Bases: `pyanaconda.ui.tui.simpleline.base.Widget`

  Create text columns

  Parameters: | columns ([(int, [...]), ...]) – list containing (column width, [list of widgets to put into this column]) spacing (int) – number of spaces to use between columns

  `render`(width)

    Render the widget to it’s internal buffer

    Parameters: | width (int) – the maximum width the widget can use
    Returns: | nothing
    Return type: | None

class `pyanaconda.ui.tui.simpleline.widgets.``CheckboxWidget`(key='x', title=None, text=None, completed=None)

  Bases: `pyanaconda.ui.tui.simpleline.base.Widget`

  Widget to show checkbox with (un)checked box, name and description.

  Parameters: | key (character) – tick character to be used inside [ ] title (str) – the title next to the [ ] box text (str) – the description text to be shown on the second row in () completed (True|False) – is the checkbox ticked or not?

  `completed`

    Returns the state of the checkbox, checked is True.

  `render`(width)

    Render the widget to internal buffer. It should be max width characters wide.

  `text`

    Contains the description text from the second line.

  `title`

    Returns the first line (main title) of the checkbox.

class `pyanaconda.ui.tui.simpleline.widgets.``CenterWidget`(w)

  Bases: `pyanaconda.ui.tui.simpleline.base.Widget`

  Class to handle horizontal centering of content.

  Parameters: | w (base.Widget) – widget to center

  `render`(width)

    Render the centered widget to internal buffer.

    Parameters: | width (int) – maximum width the widget should use

## Module contents