Hacker News new | past | comments | ask | show | jobs | submit login
Show HN: Python lib for rich text, markdown, tables, etc. in the terminal (github.com)
362 points by willm 59 days ago | hide | past | web | favorite | 47 comments



Other great tools in the python terminal sphere are colorama, blessings and urwid.

Colorama is just for cross platform colouring, blessings is a very elegant wrapper over curses which is still useful for not-fullscreen things, and urwid is a full-blown widget library for TUI stuff.


please also consider blessed, an API-compatible fork of blessings that adds Windows 10 support, 24-bit color, keyboard input, and more. https://blessed.readthedocs.io/en/latest/intro.html#brief-ov...


Don’t forget prompt-toolkit. Notably it is a dependency of the truly excellent IPython shell.


Lovely work, and I feel sad that this kind of labor inside a teletype emulator is something we consider anything but niche nostalgia in 2020.


I felt for sure we would have Minority Report interfaces by 2020, but looks like we're stuck with terminals until retirement.


I'm blown away. That's amazingly gorgeous!


Thanks!


Reminds me of my own Marked-Man utility [1], but this is way prettier. Definitely will have to check this out. Maybe I'll redo marked-man with this lib.

[1]: https://github.com/ashton314/marked-man


This looks great. I love stuff like this, especially that it is cross platform. One thing that would be nice to see is a list of which terminals are supported, or at least what the various terminals support.


Thanks. Should work with any xterm compatible terminal, and Windows legacy terminal.


Perfect timing.

I was looking at Urwid (http://urwid.org/) last night for a new project. Urwid is a console user interface library for python.


It's beautiful, but what I love most is the detailed README. Thank you for the attention to detail.


I'll add my grateful thanks.

Rich has already become my go-to tool for various Python stuff. I use these days Code's Python file with notebook cell comments. With this I can use console and Jupyter Notebook style rendering depending on wether I'm using regular IPython or Code's Interactive Window. I'm adapting my console printing to leverage Rich's features for Django querysets and other objects I'm dealing with. Rich gives me poor man's Jupyter Notebook widgets. Now I don't need to switch to ipynb files for browser based JS widgets much at all.


Good to hear its useful to you. :)


Related to this - is there a way to have a similar rich-styling library designed for email outputs?

I have some daily reports generated by a python script via cron. The script currently outputs plaintext and the email just adds <pre> tags around the output, for formatting purposes. Some spicier formatting would be nice.


There is an method to export the terminal as HTML. See https://rich.readthedocs.io/en/latest/reference/console.html...

Here is an example of the output https://rich.readthedocs.io/en/latest/appendix/colors.html


Excellent ! Really love the traceback coloration, would love to have that enabled by default, should probably check pythonrc if it can hook that up. Also, RST support would be nice to render docstrings. Also, nice sphinx docs dir, perhaps enable rtfd.io or something that will publish them somewhere as HTML ?


Some good ideas there. I’m hoping that people will build such things on top of Rich. I don’t want to add much more to the core lib...


Well I have just finished a sub-optimal color implementation with also my own print() implementation in https://yourlabs.io/oss/cli2 and I'd be willing to throw another week at it, but didn't really identify how rich could help exactly, if you want to open a ticket there then we can start a discussion

See some screenshots:

https://yourlabs.io/oss/cli2/uploads/1bb0d9278047b4656f97ebb...

https://yourlabs.io/oss/cli2/uploads/8692ed0815082af8a903619...

Still working on the rendering part

Keep up the great work


I have a short block of code I put in a lot of projects with just color output and formatting. But now I really want to start using this.

I like that it's cross platform and you can do very simple things or very complex formatting. This is super neat.


This is great! Will certainly be using it in all my command line tools and scripts. Particularly the log handler. Also, like how it has special support for Jupyter notebooks.

Thanks for developing this.


Excellent work, kudos! By the way, as a freelance software developer, do you work with Flask or other frameworks (instead of Django), if needed?


Thanks. Yeah, I've worked with a variety of web frameworks, including Flask.


My pleasure. Great, will keep it in mind for potential future collaboration. ;-)


Very cool, looks nice enough to try throwing it in my projects right now (since I've never settled on a proper output formatter).


Really cool esp the table stuff and pretty printing list and dicts in color.

This might be useful to integrate into pandas, BeautifulSoup etc


Is anyone able to get this working in PyCharm?

I can get it working on both a shell Python and iPython console, but not in the PyCharm console.


Never tried PyCharm. Do you know if it handles Color normally?


File a bug report with JetBrains.


This really rocks, man, can't wait to use it. I used to use 'Clint', but this is even more robust.


This is SO cool! Amazing collection of features, really clean API design. I had no idea how much I wanted this.


Came to echo many others here - great work and fantastic attention to detail. Thanks for your effort.


Gracias


Looks great! Any chances of curses or other TUI integration, or is that out of scope for the project?


I had a vague notion of building some kind of UI on top of Rich, but tbh I want to reclaim some spare time after 1.0.


Thanks for making this and thanks for making time to take care of yourself! Cultivating your creative energies is an achievement in itself.


It would be awesome for manpages and vim helpfiles to have formatting and color like this.


If you're willing to use zsh, there's an oh-my-zsh plugin to color the manpages, and you can adjust the colors as described here [1].

[1] https://unix.stackexchange.com/questions/501156/personalize-...


Thanks, I'll check this out.


This is awesome. I’ve used termcolor and urwid in the past, will give this a shot.


This is really cool! How did you even go about building something like this.


Wow. That progress bar - I’m sold. Looking forward to trying it out


I've been using "rich" for last month and I love it. It makes nested progress bars easy. There is still a lot left to desire but it is amaze balls.


Awesome work, the Jupyter notebook support is really appreciated!


Absolutely love this. Will implement it in my CLI games.


I'd love to see that! Tweet @willmcgugan when you have something :)


Right on time




Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact

Search: