Questions tagged [rich]

Rich is a Python library for rich text and beautiful formatting in the terminal.

99 questions
0
votes
1 answer

How to print a dictionary in a `rich.panel.Panel` object?

As the question says, I want to pretty print a dictionary such as locals() but in a Panel object (surrounding the dictionary in a nice rectangle). On trying the naïve approach, i.e., from rich.panel import Panel from rich import…
Yesh
  • 976
  • 12
  • 15
0
votes
1 answer

How to format print statement with ANSI Escape Codes using variables?

I know I can do print(f"\033[32m{newList[0]}\033[0m", f"\033[32m{newList[1]}\033[0m") to print a list value in color, But how would I make the 32m into a variable and make it work? How would I make the 32m changeable with a variable? Ex. dic = { …
edwardvth
  • 41
  • 3
0
votes
0 answers

How to save colorized output text from terminal to local file?

I'm using Python rich to print colorful texts onto the terminal. The code I used is something like this: from rich import print print(f'[bold]Param Not Found[/bold]: [yellow]{key}[/yellow] in Section [cyan]{sec}[/cyan]') The output in terminal…
Obsidian
  • 799
  • 1
  • 6
  • 18
0
votes
0 answers

Python rich encoding issue with with Windows command prompt

I tried something simple like: with console.status("Processing...", spinner='aesthetic') as status: console.print(" ✓") The expected view should be like this (copied from Pycharms command line): ▰▰▰▰▰▱▱ Processing ✓ When I run the same script…
CodeCannibal
  • 324
  • 6
  • 21
0
votes
1 answer

How can I update a rich progress bar when the associated function is called from a thread?

I intend to update my rich progress bar when the function that would have caused the progress is happen is called by spawning a thread. The progress bar is initiated but does not progess. import random import time from utils.log_util import…
Pawan
  • 99
  • 1
  • 13
0
votes
1 answer

How to yield rich.progress from another python script using with statement?

I have a basic rich progress bar implemented like this: import time from rich.progress import * with Progress(TextColumn("[progress.description]{task.description}"), BarColumn(), TaskProgressColumn(), …
Pawan
  • 99
  • 1
  • 13
0
votes
1 answer

rich center a renderable in Layout

I've been using the rich library and I have a layout that displays a table at the top of the layout, but I want it to be centered. I've looked in the documentation and wasn't able to find anything. Layout doesn't take a justify argument. Here is the…
0
votes
2 answers

How to export Tree object from Rich library to a text(.txt) file in Python?

Is there anyway to export tree object from Rich? from rich.tree import Tree from rich import print as rprint tree = Tree("Family…
Dolan
  • 29
  • 1
  • 5
0
votes
2 answers

How to integrate Rich with Python curses?

I'm thinking of creating a CLI app using python curses and rich libraries. As curses requires addstr method to print text to string, I'm unable to print using rich. Is it possible to integrate these two libraries? Following codes don't work…
Sharukh Rahman
  • 327
  • 3
  • 12
0
votes
2 answers

Can't get progress bar to work in python rich

i'm trying to add a progress bar with rich to my code. However, while the code is running, the bar only updates to 100% after it's finished. Can I have any help? My code: theme = Theme({'success': 'bold green', 'error': 'bold red',…
Thomas
  • 1,214
  • 4
  • 18
  • 45
0
votes
1 answer

Colorizing Text within Rich Tree

Im building some trees within Rich. However Im outputting obj repr() and also Python object details that Rich only seems to want to display if I pass the data to the tree branch as a string. i.e. tree = Tree(str(type(root_obj))) My question is this…
felix001
  • 15,341
  • 32
  • 94
  • 121
0
votes
1 answer

Display ellipsis when Rich Layout scrolls past end of screen/console

Is it possible to configure rich.Layout() to indicate when the number of items in the layout has exceeded the display size of the current layout? I would like to be able to tell programmatically when the code is attempting to display too many items…
JS.
  • 14,781
  • 13
  • 63
  • 75
0
votes
1 answer

Run python.exe with Windows Terminal instead of Command Prompt

Recently I am playing around with Rich. It's really helpful while debugging and tracking code running progress. However, if I use task scheduler to auto-run python script, it will open command prompt to run the script instead of others like Window…
0
votes
1 answer

Python: make Rich not style a string

I'm using rich to style the outputs in the terminal. I need to style random generated text that sometimes have within itself characters that make Rich style it ("[words]", "[/]") in another way. Basically I code rich to make a string appear green…
Longino
  • 110
  • 7
0
votes
1 answer

How to highlight in rich.prompt.Prompt

I have this highlighter from rich.console import Console import rich.prompt from rich.highlighter import RegexHighlighter from rich.theme import Theme class Highlighter(RegexHighlighter): base_style = "help." highlights =…
Ibrahim
  • 798
  • 6
  • 26