Rich is a Python library for rich text and beautiful formatting in the terminal.
Questions tagged [rich]
99 questions
2
votes
1 answer
Textual: UI is not updating after change the value
I am trying to build a simple TUI based app using Python's textual package. I have one left panel where I want to display list of items and on right panel I wan to show details of the selected item from left panel. So I want add items in the left…

Ropali Munshi
- 2,757
- 4
- 22
- 45
2
votes
1 answer
Textual (Python TUI) - Enabling long-running, external asyncio functionality
Textual is considered as a front-end to consume events (e.g., using Redis' PUBSUB to consume and show incoming events and data).
Below is generic code attempting a background async task to run indefinitely while preserving all of Textual's…

GG_Python
- 3,436
- 5
- 34
- 46
2
votes
1 answer
Why can't Python rich print text styles, only colors, on Windows command line?
The problem is that I can't print any text style.
This is my code, and I don't think it's faulty:
from rich.console import Console
console = Console(highlight=False)
console.print("Test print")
console.print("[green]Test print…

Oxunum
- 25
- 5
2
votes
2 answers
Textual (python) - how to add click event in simple Text object?
I'm trying to get it so I can add links in text rendered by Textual.
My text may have multiple links, for example:
Hello [@click=hello]World[/] there, how are you?
This is a test of [@click=more] more info[/] being clickable as well.
In this simple…

Brad Parks
- 66,836
- 64
- 257
- 336
2
votes
0 answers
How to return to PyCharm's interactive pydev debugger/REPL on a breakpoint with "Emulate terminal in output console" enabled in the run configuration?
I'm using the rich library for progress/status indicators as well as coloring the log output to more easily make sense of it at a glance.
To enable rich's formatting in PyCharm's pydev debugger, one has to enable "Emulate terminal in output console"…

jrbergen
- 660
- 5
- 16
2
votes
2 answers
Parsing Json in Python using Rich - Why Does This Happen?
I am using the rich library to parse json data retrieved with aiohttp. It works great printing the data directly from the API, formatting nicely (with line breaks so that it is not hard to read):
{
'city': 'Haidian',
'region_code': 'BJ',
…

Chev_603
- 313
- 3
- 14
1
vote
1 answer
Unable to display two tables (side by side) inside a panel
Using Python (version: 3.10.6) and the Rich (version: 13.3.1) package, I'm attempting to display two tables side by side inside a panel, like this:
from rich.panel import Panel
from rich.table import Table
from rich.console import Console
console =…

Beatdown
- 187
- 2
- 7
- 20
1
vote
1 answer
redirecting rich.inspect to file?
I am trying to troubleshoot why program receiving one set of parameters works (call it v1), while another call with almost the same parameters fails (call that v2).
So I want to diff some complex nested data structures. Trying a yaml dump resulted…

JL Peyret
- 10,917
- 2
- 54
- 73
1
vote
2 answers
construct a python rich tree from list of descendants
I am trying to construct a python rich.Tree from a list of descendants, d.
d = {0: [1, 2], 2: [3, 4, 5], 4: [6, 7]}
I expect to get something like this:
# manually constructed string
expected = \
"""
0
├── 1
└── 2
└── 3
└── 4
└── 6
…

acortis
- 400
- 3
- 15
1
vote
1 answer
rich.table prints unicode when I want ascii
I am trying to print MAC address using python rich library. Below is code. The ":cd" in the MAC address get converted to an actual CD disk emoji. How to prevent that from happening?
from rich.console import Console
from rich.table import…

Akhil Kadway
- 13
- 3
1
vote
1 answer
get tree view from a dictionary with anytree or rich, or treelib
I read the manual from https://anytree.readthedocs.io/en/latest/#, but I didn't figure out how to translate a dictionary to tree view, anyone can help?
data = {
'Marc': 'Udo',
'Lian': 'Marc',
'Dan': 'Udo',
'Jet': 'Dan',
'Jan':…

user1334609
- 381
- 4
- 12
1
vote
1 answer
VSCode/Jupyter interfering with Rich (log formatting library for Python) and I see an > for each output
Here is what I am seeing, the sign to the left of each output
How do I make that go away? Again I am using VSCode/Python and Jupyter Notebooks
The outputs or like log.info("some text")
From what I have read so far it seems to be because rich is…

MiniMe
- 1,057
- 4
- 22
- 47
1
vote
1 answer
Go through multiple lists and add them to a row in order using rich
I have these lists that I want to go over and add each one to a row in order, for example:
gladiators, 1993, $140,863,596
I tried using a list comprehension and it didn't work.
from rich.console import Console
from rich.table import Table
table =…

PunchCake
- 13
- 4
1
vote
0 answers
Updating Textual widgets in place
I have built the following app that will show a text description. The user then selects the correct category (by pressing one of the SelectButtons) for this description and presses the "next" button (ActionButton). In doing so, the selected cateogry…

KOB
- 4,084
- 9
- 44
- 88
1
vote
1 answer
Set the background of python console to an rgb value?
I'm working on a little side project console-based python script. I'm using a module called rich to add colours but i was wondering if you could also set the background colour as well.
I know the color command exists but it's very limited.
Any help…

Spooky
- 81
- 1
- 6