Library for easily creating text interfaces that look like Linux’s top program.
It is built on top of urwid but requires no knowledge of urwid itself.
Free software: MIT license
Documentation: https://topshape.readthedocs.io.
Python versions supported: 2.7, 3.3, 3.4, 3.5, 3.6
Quickstart
Here’s an example of how to use TopShape:
from topshape import TopShape
# The columns are a list (or tuple) of dictionaries. Each
# dictionary defines a column in the body
columns = ({'label': 'header1'},
{'label': 'header2'},
{'label': 'header3'})
# The body function will be passed as a callback that must
# return a 2-dimensional array everytime it's called.
def body():
return [[str(i*j) for i in range(3)] for j in range(10)]
# The header function will be passed as a callback that must
# return a string everytime it's called.
def header():
return 'This is the header!'
# The footer function will be passed as a callback that must
# return a string everytime it's called.
def footer():
return 'This is the footer!'
def handle_q(app):
app.exit()
def handle_f(app, answer):
# do something with the answer
# ...
# key_map maps keys pressed to callbacks
key_map = {'q': handle_q,
'f': (handle_f, 'Enter some text here:'}
app = TopShape.create_app(columns, body, header, footer,
key_mapping=key_map)
app.run()
Output:
Output (waiting for input from user):
There is also a more complete example here which is a clone of the linux top program.
Screenshot:
Credits
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Release files for topshape 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| topshape-1.0.0.tar.gz | 102.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| topshape-1.0.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 112.9 kB
Release files / topshape-1.0.0.tar.gz
| Download URL | topshape-1.0.0.tar.gz |
|---|---|
| Size | 102.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
464b0838c38e89e9c4b6962bf67fb05cf1fc819a4eac3f26b57bbf56c80c2801
|
|
BLAKE2b-256 checksum How to use checksums |
118fd3bd7541f7fd9014642b9ba8a7947aa717a52ff1a64615a0d35bd08eaa1e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / topshape-1.0.0-py2.py3-none-any.whl
| Download URL | topshape-1.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 10.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
b771fbe21b27f05c12ec1197bc5bf8d0690fe9cd89c07f21b7a33b1386855da5
|
|
BLAKE2b-256 checksum How to use checksums |
9cb080f3a3815b0a72f6144a4730c69738b0b8cd3d3f6a8215361adaef5a6efc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |