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.3.4.tar.gz
(10.0 kB
view details)
Built Distribution
File details
Details for the file pyTerminalUI-1.3.4.tar.gz
.
File metadata
- Download URL: pyTerminalUI-1.3.4.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2840e9cc15ae01ba965c70faf17aa010212f06f482cd2aae0f6881e92d870b6b |
|
MD5 | f73878a2f30c1dfc40788e890ce3168d |
|
BLAKE2b-256 | 43a91983a663297215d00939a15c4ef29624cb4748695737ff9f1cea662b0fc0 |
File details
Details for the file pyTerminalUI-1.3.4-py3-none-any.whl
.
File metadata
- Download URL: pyTerminalUI-1.3.4-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd3452a7721ff2e27802a6256a687a481fe2c33beea76dd94d722536948eb9a0 |
|
MD5 | f6236c9b45f9f31becea9917477688f2 |
|
BLAKE2b-256 | 0b76780909043f4e43fd7c1695730e0e62403dcd01114f3cf748dc3fee7c254c |