Skip to main content

A set of utilities for use in a terminal

Project description

terminalutilities

A set of utilities for use in a terminal.

Progress Bar

A progress bar used to track the progress of a value from 0 to some maximum value, printing in-place (overwriting) this progress.

Usage

Initialise the bar by creating a ProgressBar object, passing at least a title and a maximum value, then call Update with the new value. Once the value has reached its maximum, call Complete to finalise the bar and continue with the program.

Example

n = 999999
pb = terminalutilities.ProgressBar("Doing", n)
x = 0
while x < n:
    x += 1
    pb.Update(x)
pb.Complete()

Selection Menu

A selection menu used to allow the user to execute one of a set of prebuilt commands.

Usage

Set up a list of 'options', which are dictionaries with keys

  • name: The name of the option
  • aliases: A list of all the words that will trigger this option
  • desc: A description of the option
  • func: The function to be executed upon selecting this option; such a function must take in a single argument args which is a list of all words given after the trigger word (e.g. inputting 'test arg1 arg2' makes args == ['arg1', 'arg2']; inputting 'test' makes args == []).

Two options are included by default: "Help", which displays a list of all the options available to this menu; and "Quit", which quits the menu.

The menu will continue prompting the user until one of the functions it calls returns something not None (the function for "Quit" returns -1)

Example

def TestOption(args):
    print("test option's function is working")
options = [ {"name": "testoption",
             "desc": "this is a test option",
             "aliases": ["testoption", "test", "t", "testop"],
             "func": TestOption} ]
SelectionMenu(options)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

terminalutilities-0.0.5.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

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

terminalutilities-0.0.5-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

Details for the file terminalutilities-0.0.5.tar.gz.

File metadata

  • Download URL: terminalutilities-0.0.5.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for terminalutilities-0.0.5.tar.gz
Algorithm Hash digest
SHA256 380c660968ac6826e5e9258c1a7bffb7e744a3ee4c0b96ec08278e12b1ed9a13
MD5 0ef6f6db4de54993e1b1c390d3fb412f
BLAKE2b-256 c88c3fa5abcc33e27e1a14654d326d983760af14f8fb7c358014dee4942d7500

See more details on using hashes here.

File details

Details for the file terminalutilities-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: terminalutilities-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 14.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for terminalutilities-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 f6aebb1910431f5706b750a6573bd3c8e0d24d1cd36e46fb688e0a2b7fb16c0c
MD5 edce87aca900a4f0a61689f213a12d52
BLAKE2b-256 1fd9c417440953b5708f2075f3b7b7470952416391ff1803ab655715b59b6936

See more details on using hashes here.

Supported by

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