pylib.tui module¶
TUI module.
- Date
2020-01-13
-
class
App(delay=5)[source]¶ Bases:
objectTUI text-based user interface
initscr is the encapsulation window object of the stdscr stdsc is the curses.initscr
-
class
StdOutWrapper[source]¶ Bases:
objectSend print to stdout (print to the standard console).
- Example
# catch all prints into StdOutWrapper with StdOutWrapper() as mystdout: # begin curses (curses.initscr(), ...) # do your stuff here # print("foo") # you can also output mystdout.get_text() in a ncurses widget in # runtime # end curses (curses.endwin()) # go back to normal state and print all catched prints to stdout
-
class
Window[source]¶ Bases:
object-
border(title='', footer_left='', footer_right='', style='horizontal')[source]¶ Set border around the window with optional title and footer labels.
- Parameters
window (curses.window) – the window to draw a border
title (str) – the title for the window (default = “”)
footer_left (str or list) – the footer label (default = “”). If footer_left is a list than every element of the list will be printed sperated by one column. This is useful to not overwright the border with a space character.
-
text(string, padding_left=0, padding_top=0, attribute=0, color_pair=0)[source]¶ Test to screen. If multiline than keep the x position for each new line.
- Example
text(stdscr, 2, 1, "1 - Show test page") text(stdscr, 3, 1, "h - Show help page") text(stdscr, 4, 1, "q - Exit") text(stdscr, 2, 1, "1 - Show test page\\n" + "h - Show help page\\n" + "q - Exit")
Note
Writing in the last char of the window (last row bottom and last column right) is suppressed
-
textbox(height, width, y, x, borders=False)[source]¶ Add sub window.
- Parameters
parent_window (curses.window) – the parent window
height (int) – the height of the sub window. The reference point of the sub window is the top left corner.
width (int) – the width of the sub window. The reference point of the sub window is the top left corner.
y (int) – the y coordinate (position) of the sub window. Start from the top.
x – the x coordinate (position) of the sub window. Start from the left.
- Returns
the sub window content and decoration
- Return type
(curses.window, curses.window)
-