Skip to main content

based on curses, ovtable is a table displayed in the terminal with Python API

Project description

ovtable

build coverage pypi support-version license commit

๐Ÿ’ป based on curses, ovtable is a table displayed in the terminal with Python API

Installation

Install via pip:

python -m pip install -U prettytable

Or install from source:

git clone git@github.com:PiperLiu/ovtable.git
cd ovtable
make refresh

Get the best experience with Monospaced Fonts! e.g. Let's get Fira Code!

Tutorial on how to use ovtable

>>> import ovtable

>>> ot = ovtable.OvTable(60, 30, True)
>>> # 60 is width, 30 is height
>>> # True means you want to use __str__
>>> # False means you want to render it (use ot.render())

>>> ot.add_row(1)
>>> ot[0, 0] = "Hello, OvTable"
>>> print(ot)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Hello, OvTable                      โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

>>> ot.add_row(2)
>>> ot[1, 0] = [("I'm red", "r"), (" ok, I'm blue", "b")]
>>> ot[1, 1] = "I am in row 2, col 2"
>>> print(ot)
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                      Hello, OvTable                      โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚    I'm red ok, I'm blue    โ”‚    I am in row 2, col 2     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

With ot[x, y] = value or ot[x, y] = [(s1, color1), (s2, color2), ...], we can render some interesting things! See ./examples/.

python examples/walker.py as below:

Why not PrettyTable?

Why created ovtable when we already have PrettyTable?

Well, mainly two reasons:

  • First, PrettyTable does not support different number of rows per line.
  • Second, our APIs is more suitable for rendering tables dynamically.

Contribution

We welcome all forms of contributions (including but not limited to issues and pull requests).

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

ovtable-0.0.3.tar.gz (5.7 kB view hashes)

Uploaded Source

Built Distribution

ovtable-0.0.3-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

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