I'm Peter, I'm a robotics educator and researcher.
- I'm currently working on a bunch of packages for robotics, machine vision and block diagram simulation.
Quick, easy and pretty display of tabular data or matrices, with optional ANSI color and borders
License: MIT License
Introduce Row
and Cell
classes to allow customizing per-row and per-cell styling (alignment, color, and style). This is useful, for example, to highlight specific rows or specific cell values in a large table using, e.g., style="reverse"
# proposed syntax only!
table.add(Row(["hello-world", "1.0.0", "2023-07-28"], style="reverse")) # row-level override
table.add(Row([Cell("foo-bar", style="bold"), "0.1.0", "2023-07-28"])) # cell-level override
I've been trying to get this library working on jupyterlite, but am running into a dependency issue.
Here's what it looks like when I try installing it with jupyterlite:
And this is the error it throws:
Column headbgcolor
and colbgcolor
settings are typically used as cell background colors, so they should occupy the entire cell width and not be affected by the ANSITable colsep
setting that adds left/right padding to a header or column cell. This padding is currently being applied to the background colors instead of just the text, rendering empty strips along the inner borders.
from ansitable import ANSITable, Column # ansitable 0.9.7
table = ANSITable(
Column("Column 1", headalign="<", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="white", colstyle="bold", colbgcolor="blue"),
Column("Column 2", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="light_magenta", colbgcolor="blue"),
Column("Date", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="^", colcolor="chartreuse_3b"),
border="thick", bordercolor="cornflower_blue", colsep=4,
)
table.row("hello-world", "1.0.0", "2023-07-28")
table.row("foo-bar", "0.1.0", "2023-07-28")
table.print()
This issue is related to, and may be irrelevant once resolved by #8 (headbgcolor and colbgcolor should not be affected by colsep).
The natural column width is determined by the widest column value, whether that's the header or one of the rows. That same column width should be applied to both headbgcolor
and colbgcolor
, but it is currently not being applied to colbgcolor
.
In the example below, the "Date" header is padded—as expected—by the longer "2023-07-28" values, but the wider "Column 2" header is not reflected in the padding of shorter version numbers like "1.0.0". The same is true with column 1 row values.
from ansitable import ANSITable, Column # ansitable 0.9.7
table = ANSITable(
Column("Column 1", headalign="<", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="white", colstyle="bold", colbgcolor="blue"),
Column("Column 2", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="light_magenta", colbgcolor="blue"),
Column("Date", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="^", colcolor="chartreuse_3b"),
border="thick", bordercolor="cornflower_blue", colsep=4,
)
table.row("hello-world", "1.0.0", "2023-07-28")
table.row("foo-bar", "0.1.0", "2023-07-28")
table.print()
Colored doesn't follow semantic versioning, and version 1.5.0 introduced breaking API changes. In particular, the functions fg
and attr
were renamed fore
and style
, respectively. This means that the following lines:
Lines 10 to 16 in 1b05990
will always lead to _colored = False
, even if colored is installed. Since ansitable's dependencies do not specify a version for colored, this is a problem for ansitable.
When a table border is shown, no matter what the header or column alignment is set to for the first, left-most, column, the colsep
setting, which should be better known as "padding", does not get applied on the left side of that column. For other columns, this setting appears to be working fine.
from ansitable import ANSITable, Column # ansitable 0.9.7
table = ANSITable(
Column("Column 1", headalign="<", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="white", colstyle="bold", colbgcolor="blue"),
Column("Column 2", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="<", colcolor="light_magenta", colbgcolor="blue"),
Column("Date", headalign="^", headcolor="white", headstyle="bold", headbgcolor="blue",
colalign="^", colcolor="chartreuse_3b"),
border="thick", bordercolor="cornflower_blue", colsep=4,
)
table.row("hello-world", "1.0.0", "2023-07-28")
table.row("foo-bar", "0.1.0", "2023-07-28")
table.print()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.