Skip to main content

Sourcecode on GitHub Sourcecode License GitHub tag (latest SemVer incl. pre-release) GitHub release (latest SemVer incl. including pre-releases) GitHub release date Dependents (via libraries.io)
GitHub Workflow - Build and Test Status Codacy - Quality Codacy - Coverage Codecov - Branch Coverage Libraries.io SourceRank
PyPI PyPI - Python Version PyPI - Status Libraries.io status for latest release Requires.io
Documentation License Documentation - Read Now!

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

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

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.9.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyTooling.TerminalUI-1.5.9-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file pyTooling.TerminalUI-1.5.9.tar.gz.

File metadata

  • Download URL: pyTooling.TerminalUI-1.5.9.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for pyTooling.TerminalUI-1.5.9.tar.gz
Algorithm Hash digest
SHA256 7dfe4754f8edb5b08fe1bd6111a6665a0dfe7f42288d40575bf7e490cb86b10a
MD5 4bcc4167863719e8e5b47e60d7b74dc1
BLAKE2b-256 a2df5154688da8f8a4819031d3477657462baa7c3279b15a4845526ce276e435

See more details on using hashes here.

File details

Details for the file pyTooling.TerminalUI-1.5.9-py3-none-any.whl.

File metadata

File hashes

Hashes for pyTooling.TerminalUI-1.5.9-py3-none-any.whl
Algorithm Hash digest
SHA256 2217751fc2fffdde0c87263990328e820e302503e3c499f21b2f934857e6dc60
MD5 65630109497d8229ae440f5466137726
BLAKE2b-256 364c721c66466e8b42da556bc0084eaa0c1385bb617aaa7b9584d79c682930de

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.5.9 This release

2 files

1.5.8

2 files

1.5.7

2 files

1.5.6

2 files

1.5.5

2 files

1.5.4

2 files

1.5.3

2 files

1.5.1

2 files

1.5.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page