advanced_tui

This module defines the AdvancedTUI class.

AdvancedTUI uses urwid. If urwid hasn’t been installed, CommandLineUI should be used instead.

class turboctl.ui.advanced_tui.AdvancedTUI(script, inputfile, outputfile, palette=())

A text-based user interface combining a terminal-style command line interface and a text screen.

display

A text field for presenting information to the user. Use display.set_text() to change its contents.

Type:

urwid.Text

command_line_interface

A command-line interface for issuing commands, located below display.

Type:

ScrollableCommandLines

__init__(script, inputfile, outputfile, palette=())

Initialize a new AdvancedTUI.

Parameters:
  • script – The program that this UI controls. It should be wrapped in a callable object so that calling script() executes it. The UI communicates with the program through inputfile and outputfile; the program should read its input from inputfile and send its output to outputfile.

  • inputfile (file-like object) – User input entered into the UI is written into this object.

  • outputfile (file-like object) – Output printed on the screen by the UI is read from this object.

  • palette (iterable of palette entries) – The palette used for the UI. This is passed to the initializer of urwid.MainLoop. The format used by palette entries is specified in the documentation of urwid.BaseScreen.register_palette().

run()

Run the program and the UI loop in parallel threads. The UI loop beaks automatically when the program ends.

Warning

If the UI loop (which is executed in the main thread) crashes, the program (executed in a parallel thread) will probably be left waiting for input in a blocking state. Safeguards to prevent this should be built into code that uses AdvancedTUI; for example, this method may be called in a with or a try-finally block that makes sure the program is closed when the block is exited.