The Region

The Region is the home of your elements. It handles their positioning and drawing.

Creation

from pyTermUI.region import Region
from pyTermUI.position import Position


region = Region("A default terminal size region.", Position(0,0), Position.DEFAULT_TERM_SIZE())

Properties

Instance

ui: UI - The UI the region is contained in.

start: Position - Contains the Position object representing the top left corner of the region.

size: Position - Contains the Position object representing the size of the region.

pack: dict - A dictionary containing Position objects containing the coordinates required to place the object above, below, and to the right of the region.

end: Position - Contains the Position object representing the bottom right corner of the region.

color: int - The color of the regions borders, defaulting to the default_color variable of its parent UI.

text: str - The title of the region.

framed: bool - Whether the regions borders should be drawn to the screen. Default is True.

visible: bool - Whether the region is drawn at all. Default is True.

elements: list - A list of all elements added to the region using Region().add_element().

sOrigin: Position - A shorthand for the inside top left corner of the region.

eOrigin: Position - A shorthand for the inside bottom right corner of the region.

Methods

Instance

add_element(element: Element) -> None - Add an Element to the region, see: The Basic Element

set_text(text: str) -> None - Set the title of the region.

inBounds(position: Position) -> Bool - Determine whether a Position is absolutely within bounds of the region.

move(position: Position) -> None - Move the region absolutely and recalculate its relative packing dictionary.

resize(size: Position) -> None - Resize the region absolutely and recalculate its relative packing dictionary.

calc_pack() -> None - Recalculate the relative packing dictionary.

hidden(visibility: bool) -> None - Whether the region and its elements are drawn at all.

addstr(y: int, x: int, string: str, options=0) -> None - A curses shorthand for stdscr.addstr() with added functionality to remove overdrawing.

error(text: str) -> None - Forcefully deactivate the UI, clean up curses setup and print some text to the console. Mainly used for debugging applications.