A set of helpers to implement a text user interface (TUI) in a terminal.
Project description
pyTooling.TerminalUI
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: Path, terminal):
super().__init__(terminal)
if not configFile.exists():
self.WriteError(f"Config file '{configFile}' not found.")
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.4.tar.gz
(13.9 kB
view hashes)
Built Distribution
Close
Hashes for pyTooling.TerminalUI-1.5.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ea60b3693c3f457a4ac3ee5c1de5773e1f399ec380cc2abbcdf2f083fa15e0 |
|
MD5 | 44a92cb0a7919baa935554ce34fc2b7a |
|
BLAKE2b-256 | 6a80d56b228d9cb1acd41569abb2cde49a20f179d346be686719829fd2a56443 |
Close
Hashes for pyTooling.TerminalUI-1.5.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c37957e60c938022226b09c0ceadec86e2f23f5b3378600cd1fe4895ae640f80 |
|
MD5 | f6d223bb6c95e669931b4d8c91635cea |
|
BLAKE2b-256 | f004aaf096edbcdb7259433dc031734971bb0c83d7f8d8ee0fe20b1b8a852f6f |