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 pyTerminalUI 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 pyTerminalUI 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)
License
This Python package (source code) is licensed under Apache License 2.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
pyTerminalUI-1.4.0.tar.gz
(14.0 kB
view details)
Built Distribution
File details
Details for the file pyTerminalUI-1.4.0.tar.gz
.
File metadata
- Download URL: pyTerminalUI-1.4.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed50f9329dcc2536ef7b39a5627705dcb8eaeab240b7e23bf7357f9fba6eaf45 |
|
MD5 | d9997e1f474a89ad677041554b310489 |
|
BLAKE2b-256 | 45d316a110470e7a3aeceaaf659c270300624a0fdb99e68968a98905ba3407c6 |
File details
Details for the file pyTerminalUI-1.4.0-py3-none-any.whl
.
File metadata
- Download URL: pyTerminalUI-1.4.0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 695f2cb6d8db0755981b45b2d7d53d4d86d3bba80e51116932f579959cacb692 |
|
MD5 | c64b6c02ad0919b222f290eea3744775 |
|
BLAKE2b-256 | 9a40dca1f5cdac67c3c8d363279cd4222f3b9667b7e3dbb79c61962af39eef4c |