From 3d45107e9e9e080a1f036319cab35fb74467aebc Mon Sep 17 00:00:00 2001 From: Ram Basnet Date: Sun, 10 Nov 2024 20:44:51 -0700 Subject: [PATCH] add rich libaray --- .../Ch00-IntroCourseTableOfContents.ipynb | 1 + notebooks/Ch10-2-RichLibrary.ipynb | 120 ++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 notebooks/Ch10-2-RichLibrary.ipynb diff --git a/notebooks/Ch00-IntroCourseTableOfContents.ipynb b/notebooks/Ch00-IntroCourseTableOfContents.ipynb index 9fb5628..4fec200 100644 --- a/notebooks/Ch00-IntroCourseTableOfContents.ipynb +++ b/notebooks/Ch00-IntroCourseTableOfContents.ipynb @@ -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" ] diff --git a/notebooks/Ch10-2-RichLibrary.ipynb b/notebooks/Ch10-2-RichLibrary.ipynb new file mode 100644 index 0000000..87171b6 --- /dev/null +++ b/notebooks/Ch10-2-RichLibrary.ipynb @@ -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": [ + "
🔥 Hello, World! 🧛\n",
+       "
\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 +}