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 library 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.3.tar.gz
(8.1 kB
view hashes)
Built Distribution
Close
Hashes for pyTerminalUI-1.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04bb197c50ac5753a9a38dca582dbcc82ae60d68507cebe1ed5c8c9db1c913ac |
|
MD5 | 7ed698cbae11b55f8a355f12d26d97a9 |
|
BLAKE2b-256 | 529ae4b22bdd12f2e387198e0daf06152f0ce1153a95adb20420a995faf6ed67 |