rich logo rich: constructions

1 2 3 4 5 6 7 8 9 10 11 12
Notes

Rich is a flexible system of components that can really click together too. To demonstrate this we'll combine the Columns, Panel and Markdown classes together in the example below.

from rich.columns import Columns
from rich.console import Console
from rich.panel import Panel
from rich.markdown import Markdown

md1 = """
# Hello World

## This is Markdown

And it renders *very* **nicely**!
"""

md2 = """
## This is Markdown, Again

With code!

```python
print("hello world")
```
"""

console = Console(record=True)
panel_1 = Panel.fit(Markdown(md1), title="panel one", width=60)
panel_2 = Panel.fit(Markdown(md2), title="panel two", width=60)
console.print(Columns([panel_1, panel_2]))