Skip to content

Commit

Permalink
add rich libaray
Browse files Browse the repository at this point in the history
  • Loading branch information
rambasnet committed Nov 11, 2024
1 parent c2760d8 commit 3d45107
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions notebooks/Ch00-IntroCourseTableOfContents.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"### [Ch09-1 - Dictionaries](./Ch09-1-Dictionaries.ipynb)\n",
"### [Ch09-2 - Built-in Data Structures](./Ch09-2-Built-in-DataStructures.ipynb)\n",
"### [Ch10-1 - Files](./Ch10-1-Files.ipynb)\n",
"### [Ch10-2 - Rich Library](./Ch10-2-RichLibrary.ipynb)\n",
"### [Ch13 - Recursion](./Ch13-Recursion.ipynb)\n",
"### [Ch14 - OOP Introduction](./Ch14-OOP.ipynb)\n"
]
Expand Down
120 changes: 120 additions & 0 deletions notebooks/Ch10-2-RichLibrary.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Python Rich Library\n",
"\n",
"This notebook is a quick overview of the Python Rich library. Rich is a Python library for rich text and beautiful formatting in the terminal. It is a great tool for creating beautiful and interactive text-based interfaces.\n",
"\n",
"- [Rich Documentation](https://rich.readthedocs.io/en/latest/)\n",
"- [GitHub Source and Demos](https://github.com/Textualize/rich)\n",
"\n",
"## Installation\n",
"\n",
"You can install the Rich library using pip:\n",
"\n",
"```bash\n",
"pip install rich\n",
"```\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"! pip install rich"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from rich import print"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\">🔥 Hello, <span style=\"color: #800080; text-decoration-color: #800080; font-weight: bold\">World</span>! 🧛\n",
"</pre>\n"
],
"text/plain": [
"🔥 Hello, \u001b[1;35mWorld\u001b[0m! 🧛\n"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"print(\":fire: Hello, [bold magenta]World[/bold magenta]!\", \":vampire:\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Go through the following Examples on a Terminal\n",
"\n",
"- run the following examples from command line\n",
"\n",
"```bash\n",
"$ python -m rich.table\n",
"$ python -m rich.progress\n",
"$ python -m rich.status\n",
"$ python -m rich.columns\n",
"$ python -m rich.tree\n",
"$ python -m rich.panel\n",
"$ python -m rich.box\n",
"```\n",
"\n",
"- look at examples from GitHub source\n",
"\n",
"- Console API\n",
"- Styles\n",
"- Prompt\n",
"- Progress\n",
"- Table\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}

0 comments on commit 3d45107

Please sign in to comment.