A set of helpers to implement a text user interface (TUI) in a terminal.
Project description
pyTerminalUI
A set of helpers to implement a text user interface (TUI) in a terminal.
Features
- Colored command line outputs based on colorama
- Message classification in fatal, error, warning, normal, quiet, ...
- Get information like terminal dimensions from underlying terminal window
Simple Terminal Application
This is a minimal terminal application example which inherits from LineTerminal
.
from pyTooling.TerminalUI import LineTerminal
class Application(LineTerminal):
def __init__(self):
super().__init__(verbose=True, debug=True, quiet=False)
def run(self):
self.WriteNormal("This is a simple application.")
self.WriteWarning("This is a warning message.")
self.WriteError("This is an error message.")
# entry point
if __name__ == "__main__":
Application.versionCheck((3, 6, 0))
app = Application()
app.run()
app.exit()
Complex Terminal Application
This example hands over the terminal instance to a submodule, which implements
ILineTerminal
, so the submodule can also use the terminal's writing methods.
from pathlib import Path
from pyTooling.TerminalUI import LineTerminal, ILineTerminal
class SubModule(ILineTerminal):
def __init__(self, configFile, terminal):
super().__init__(terminal)
if not configFile.exists():
self.WriteError("Config file '{0!s}' not found.".format(configFile))
class Application(LineTerminal):
def __init__(self):
super().__init__(verbose=True, debug=True, quiet=False)
mod = SubModule(Path("config.yml"), self)
def run(self):
pass
# entry point
if __name__ == "__main__":
app = Application()
app.run()
Contributors
- Patrick Lehmann (Maintainer)
- and more...
License
This Python package (source code) licensed under Apache License 2.0.
The accompanying documentation is licensed under Creative Commons - Attribution 4.0 (CC-BY 4.0).
SPDX-License-Identifier: Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyTooling.TerminalUI-1.5.0.tar.gz
(14.2 kB
view hashes)
Built Distribution
Close
Hashes for pyTooling.TerminalUI-1.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7d6de27e19daf3a4e6888c309e19301b87062a7aba04ca6319b7aa2ae435509 |
|
MD5 | bfcca06edfff8cb8f422e27b536aa4e7 |
|
BLAKE2b-256 | b9657ba46cd8bc318df5fedf7b53fa88786c0f3024536e5dbc639f15bf128ed3 |
Close
Hashes for pyTooling.TerminalUI-1.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5d2ddfefbe050400a9b9369fc1956d89dec9223af2c8f186f1559d6016672c4 |
|
MD5 | f40bec4a8e49996bee8cfe0c33019512 |
|
BLAKE2b-256 | 516066f3fe904e8a86415047ed41de64924dd2d28f89cde8c4d0a55006617dce |