Rich is a Python library for rich text and beautiful formatting in the terminal.
Questions tagged [rich]
99 questions
9
votes
1 answer
Some numbers are automatically formatted using rich.console, how to prevent this?
The following code
from rich.console import Console
console = Console()
console.print("ciao-16S-123")
will print the number 123 highlighted (in blue, in my terminal).
This happens on many strings with numbers, what could be the problem
that…

Andrea T.
- 920
- 4
- 15
6
votes
1 answer
Vertical overflow of table in live display should scroll the content
I'm using a Live display to show the content of a Table which grows over time. Eventually there is a vertical overflow and in that case I'd like the oldest (i.e. topmost) rows to vanish while the most recent rows should be shown together with the…

a_guest
- 34,165
- 12
- 64
- 118
6
votes
1 answer
List of lists into a Python Rich table
Given the below, how can i get the animal, age and gender into each of the table cells please? Currently all the data ends up in one cell. Thanks
from rich.console import Console
from rich.table import Table
list = [['Cat', '7', 'Female'],
…

yeleek
- 199
- 3
- 15
5
votes
1 answer
Set a Minimum Width for Python Rich Logging (RichHandler)
I am using RichHander to format log output inside Python. While this works great locally, when I run inside GitLab, it seems to default to using a terminal that is 80 characters wide. This makes the output fairly difficult to read and scan…

DiB
- 554
- 5
- 19
5
votes
1 answer
Printing a Dict() with Rich
I'm trying to print a dict() using Pythons Rich. From my understanding, this should output the data on different lines etc. A bit like pprint.
But I'm getting:
>>> from rich import print
>>> print(output)
{'GigabitEthernet0/1': {'description': '##…

felix001
- 15,341
- 32
- 94
- 121
5
votes
1 answer
Set different background color using Rich
I found useful package rich. And want to use it in the next way:
drawing in different colors words in sentence and at different background colors.
I use next code:
from rich.console import Console
console =…

Mikhail_Sam
- 10,602
- 11
- 66
- 102
4
votes
0 answers
How can I change my color scheme for highlighting markdown text in rich (python)
I am using the rich module to enable markdown support in the terminal. However, I am using a light-themed terminal and the default colors of rich markdown highlighting look borderline unreadable. So how would I go about changing the color scheme…

Racid
- 141
- 8
4
votes
0 answers
rich.prompt.Confirm not working in rich.Progress context python
I am working on an app that uses a rich.Progress for rendering progress bars. The problem is rich.prompt.Confirm just flashes instead of showing the message and asking for the confirmation while in the Progress context.
Demo Code
from rich.progress…

bython
- 65
- 6
4
votes
2 answers
Is it possible to use background-aware color choices?
The rich project allows to specify console markup, including text color. However it seems that any color choices need to be hardcoded, e.g. using red for important messages:
from rich import print
print('[red bold]This is a very important…

a_guest
- 34,165
- 12
- 64
- 118
3
votes
0 answers
Want rich live display to print everything live without overflowing or ellipsis
I am using Rich Live, and whenever the things which are printed are more than the height of my console, Rich just shows me an ellipsis, and I have to set Live's vertical_overflow to "visible." This will show my prints live, but it will print…

MohammadHosein
- 41
- 6
3
votes
2 answers
Getting a Prompt inside a Layout using Python Rich
Is it possible to get user input using a Prompt within a Layout element using Python Rich?
My aim is to use Rich's Layout to build a full-screen window with 4 panes. The top 3, containing title, ingredients and method work fine, but I would like the…

PangolinPaws
- 670
- 4
- 10
3
votes
5 answers
Redirect print and/or logging to Panel
I have made a small application that uses a Rich to show a Live view in several Panels.
Is there a way to put standard (or rich) print statements into a particular panel?
Being able to show logging output in its own dedicated panel would also…

Ben
- 43
- 8
3
votes
2 answers
Overwriting the builtin Python Print
Nowadays I pretty much only using the Python Rich implementation for printing. i.e from rich import print.
Rather than adding this to every script I write, is there a way to replace the built-in Python print with the Rich implementation?

felix001
- 15,341
- 32
- 94
- 121
3
votes
2 answers
When I use the rich library to add colour, why does it affect the symbols around it? Is there a way to stop this from happening?
What am I trying to do?
I am using the rich library to print words out in different colours.
I have come up with the following program to do so:
from rich import print as rprint
rprint('[[green]1[/green]] Create new password')
print('[2] See…

some_user_3
- 403
- 1
- 5
- 17
2
votes
2 answers
With Python-textual (package) how do I linearly switch between different 'screens'?
With textual I'd like to build a simple program which presents me with different options I can choose from using OptionList, but one by one, e.g.
First "screen":
what do you want to buy (Car/Bike)?
+---------+
| Car |
| > Bike …

frans
- 8,868
- 11
- 58
- 132