{"id":25491525,"url":"https://github.com/iammu/fancy-print","last_synced_at":"2025-04-10T00:06:17.188Z","repository":{"id":60998234,"uuid":"546708536","full_name":"IamMU/Fancy-Print","owner":"IamMU","description":"Fancy Print is a library that makes it easy to print beautiful text in python, without much of code.","archived":false,"fork":false,"pushed_at":"2022-11-11T17:34:51.000Z","size":155,"stargazers_count":8,"open_issues_count":4,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T00:06:06.171Z","etag":null,"topics":["cli","logging","printing-package","python","python-3","python-library","python-package","terminal"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/fancyprint/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IamMU.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-10-06T14:13:44.000Z","updated_at":"2024-01-05T15:13:30.000Z","dependencies_parsed_at":"2023-01-22T15:16:08.812Z","dependency_job_id":null,"html_url":"https://github.com/IamMU/Fancy-Print","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamMU%2FFancy-Print","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamMU%2FFancy-Print/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamMU%2FFancy-Print/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IamMU%2FFancy-Print/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IamMU","download_url":"https://codeload.github.com/IamMU/Fancy-Print/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131319,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","logging","printing-package","python","python-3","python-library","python-package","terminal"],"created_at":"2025-02-18T22:17:52.534Z","updated_at":"2025-04-10T00:06:17.153Z","avatar_url":"https://github.com/IamMU.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eFancy Print\u003c/h1\u003e\n\u003ch3 align=\"center\"\u003eAn aesthetic replacement to print()\u003c/h3\u003e\n\n\u003chr\u003e\n\n\u003ch6 align=\"center\"\u003e\u003cb\u003eDevelopment Status:\u003c/b\u003e Early Development\u003c/h6\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/fancyprint/\"\u003e\n\t\u003cimg src=\"https://img.shields.io/pypi/v/fancyprint?color=blue\u0026label=PyPI\u0026logo=python\u0026logoColor=white\u0026style=for-the-badge\" alt=\"PyPI\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n# About\n\nFancyPrint is a python package, making it easier for developers to get beautiful CLI with responsiveness in regards to terminal size.\n\n# Usage\n\n## Installing FancyPrint\n\nTo install fancyprint use the following command:\n```bash\npip install fancyprint\n```\nThis will install all dependencies needed as well.\n\n## Getting Started\n\nTo start using Fancy Print, first import it.\n```python\nimport fancyprint\n```\nThis will import all the necessary functions required.\n\n### Basics\n\n#### Printing\n\nThe ``pretty_print()`` function is for printing text to the terminal. Here is an example:\n```python\npretty_print(\"This is some text\", align=Align.LEFT)\n```\n![img_2.png](Images/PrinterPreview.png)\nIt is using the default preset, which can be changed by using presets or changing argument values.\nThere are two ways one customize and use it, and they can be\nused interchangeably:\n- Using presets (recommended)\n- Using keyword arguments\n\n##### Using Presets\nPresets allow you to customize the printer and the separator, and they can be *local* presets or *global* presets.\nPresets are local when they are created for one part only(i.e Printer) and are global when they can be used anywhere\n(both in the Separator and the Printer). \n\n###### Using Local Presets\nThere are two types of local presets you can use:\n- PrinterPreset\n- SeparatorPreset\n\n**PrinterPreset**\n\u003cbr\u003e\n\u003cbr\u003e\nThe ``PrinterPreset`` is used to customize the ``pretty_print()`` function. To use it, you need to import it first.\nHere is an example of declaring a ``PrinterPreset``:\n```python\nfrom fancyprint.ftypes import PrinterPreset\nfrom fancyprint.ftypes import Color\n\nmy_custom_printer_preset = PrinterPreset(\n    delimiter_left=\"\u003c\",\n    delimiter_left_color=Color.RED,\n    \n    delimiter_right=\"\u003e\",\n    delimiter_right_color=Color.RED,\n    \n    delimiter_space_amount=10,\n    delimiter_space_symbol=\" \",\n    \n    hyphenation=False\n)\n```\nHere's the preset in action:\n```python\n[...]\npretty_print(\"Hi this is some text\", preset=my_custom_printer_preset)\n```\nThis will print the following:\n![img.png](Images/PrinterPreset01.png)\nThat looks awful right now. That is because we have a custom printer preset, but the separator is using\nthe default preset. Let's make it more good-looking by using a custom separator preset!\n\n**SeparatorPreset**\n\u003cbr\u003e\n\u003cbr\u003e\nThe ``SeperatorPreset`` is used to customize the separator, whether it is used alone or with the printer. To use it, it\nneeds to be imported first. Here is an example of declaring one:\n```python\nfrom fancyprint.ftypes import SeparatorPreset, Color\n\nmy_custom_separator_preset = SeparatorPreset(\n    delimiter_left=\"\u003c\",\n    delimiter_left_color=Color.RED,\n    \n    delimiter_right=\"\u003e\",\n    delimiter_right_color=Color.RED,\n    \n    delimiter_space_symbol=\" \",\n    delimiter_space_amount=10,\n    \n    separator_symbol=\"-\",\n    separator_color=Color.BLUE,\n)\n```\nNow let's use this preset, in the previous example:\n```python\n[...]\npretty_print(\"Hi, this is some text!\", preset=my_custom_printer_preset, separator_preset=my_custom_separator_preset)\n```\nThe above will print the following:\n![img.png](Images/PrinterCustomPreset.png)\nIt's starting to look good now, but since we are going to use one preset everywhere, *in this example*,\nwe should create a global preset.\n\n###### Using the Global Preset\nThe ``Preset`` class is used to create a global preset, and can be given to both the separator and the printer, which\nmakes it useful if the whole program is to follow a simple theme. To use it you need to import the ``Preset``, along\nwith the local presets, which make it easy to declare a global Preset. Here's an example of declaring a global preset,\nusing our previously declared local presets:\n```python\n[...]\nfrom fancyprint.ftypes import Preset\n\nglobal_preset = Preset(\n    printer_preset=my_custom_printer_preset,\n    separator_preset=my_custom_separator_preset,\n)\n```\nThe previous example, but with a global preset would like:\n```python\n[...]\npretty_print(\"Hi, this is some text!\", preset=global_preset, separator_preset=global_preset)\n```\nThis will print:\n![img_1.png](Images/PrinterCustomPreset02.png)\n\n#### Using Keyword Arguments\nIf you want to have different customizations, you could use presets, but if you only want to change some aspects of the\nprinter, you might want to use the function's keyword arguments instead. Here's a list of available customizations you \ncan do with arguments:\n- align | Align(Enum): Changes the alignment of the text\n- delimiter_left | str: Symbol for the left delimiter\n- delimiter_left_color | Color: Color for the left delimiter\n- enable_left_delimiter | bool: Whether to print the left delimiter or not\n- delimiter_right | str: Symbol for the right delimiter\n- delimiter_right_color | Color: Color to be used for the right delimiter\n- enable_right_delimiter | bool: Whether to print the right delimiter\n- delimiter_space_amount | int: Amount of space to print after/before the delimiters\n- delimiter_space_symbol | str: Symbol to be used for the delimiter space (\" \" is the default and is useful for most cases)\n- separator_left_delimiter | str: Symbol for the left delimiter of the separators\n- separator_left_delimiter_color | Color: Color for the left delimiters of the separators\n- enable_left_separator_delimiter | bool: Whether to print the left delimiter in the separators\n- separator_right_delimiter | str: Symbol for the right delimiter of the separators\n- separator_right_delimiter_color | Color: Color for the right separator delimiters\n- enable_right_separator_delimiter | bool: Whether to print the right delimiter in the separators\n- separator_symbol | str: Symbol for the separator\n- separator_color | Color: Color for the separator symbol\n- enable_separator_symbol | bool: Whether to print the separator symbol, if false then \" \" will be printed\n- separator_delimiter_space_amount | int: Amount of delimiter space in the separator\n- separator_delimiter_space_symbol | str: Symbol for the delimiter space in the separator\n- enable_back_separator | bool: Whether to print the back separator\n- enable_front_separator | bool: Whether to print the front separator\n- test_mode | bool: If you want to mess with the alignment calculations\n- testing_terminal_width | int: Artificial terminal width to use, for testing or for making something beautiful ;)\n\n##### Alignment\nThere are three alignment options available at the moment. They are left, right and center. To use alignments, you need \nto import the Align enum from the ftypes subpackage. Here are examples of using the different alignments:\n```python\n[...]\nfrom fancyprint.ftypes import Align\n\npretty_print(\"Hi, this is some text!\", align=Align.LEFT)\npretty_print(\"Hi, this is some text!\", align=Align.CENTER)\npretty_print(\"Hi, this is some text!\", align=Align.RIGHT)\n```\nThe above gives the following results:\n![img_3.png](Images/PrinterAlignmentPreview.png)\nDoesn't look too nice, let's remove some separators:\n```python\n[...]\n\npretty_print(\"Hi, this is some text!\", align=Align.LEFT)\npretty_print(\"Hi, this is some text!\", align=Align.CENTER, enable_back_separator=False)\npretty_print(\"Hi, this is some text!\", align=Align.RIGHT, enable_back_separator=False)\n```\n![img_5.png](Images/PrinterAlignmentPreview02.png)\nMuch better. You might also want some \"padding\", which is called \"delimiter space\" in the function. Let's add some\ndelimiter space to the print statements!\n```python\n[...]\n\npretty_print(\"Hi, this is some text!\", align=Align.LEFT, delimiter_space_amount=10)\npretty_print(\"Hi, this is some text!\", align=Align.CENTER, enable_back_separator=False, delimiter_space_amount=10)\npretty_print(\"Hi, this is some text!\", align=Align.RIGHT, enable_back_separator=False, delimiter_space_amount=10)\n```\n![img_6.png](Images/PrinterAlignmentPreview03.png)\nEverything looks good to this point. But you might want to see where the spaces are. You might do something like this:\n```python\n[...]\npretty_print(\"Hi, this is some text!\", align=Align.LEFT, delimiter_space_amount=10, delimiter_space_symbol=\"=\")\npretty_print(\"Hi, this is some text!\", align=Align.CENTER, enable_back_separator=False, delimiter_space_amount=10, delimiter_space_symbol=\"=\")\npretty_print(\"Hi, this is some text!\", align=Align.RIGHT, enable_back_separator=False, delimiter_space_amount=10, delimiter_space_symbol=\"=\")\n```\n![img_7.png](Images/PrinterAlignmentPreview04.png)\n#### Separation\nOther than being used in the print function, you can also use the ``separater_line()`` function to print a separator line.\nAs in like in printing, you can also use the separator with both a preset or keyword arguments. We already covered the\nseparator preset in [Using Local Presets](#using-local-presets), so it will not be in this section. \nThe following keyword arguments are available for customizations:\n- preset | Preset, SeparatorPreset: If you want to use a preset\n- delimiter_left | str: Symbol for the left delimiter\n- delimiter_left_color | Color: Color for the left delimiter\n- enable_left_delimiter | bool: Whether to print the left delimiter\n- delimiter_right | str: Symbol for the right delimiter\n- delimiter_right_color | Color: Color for the right delimiter\n- enable_delimiter_right | bool: Whether to print the right delimiter\n- delimiter_space_amount | int: Amount of delimiter space to print\n- delimiter_space_symbol | str: Symbol for the delimiter space\n- separator_symbol | str: Symbol for the seperator\n- separator_color | Color: Color for the separator\n- enable_separator | bool: Whether to print the separator symbol, else \" \" will be used\n- test_mode | bool: Whether to use test mode\n- testing_terminal_width | int: Artificial terminal width for testing or for making separator more customized ;)\n\nHere's an example of using the separate_line() function:\n```python\nfrom fancyprint.printer import separate_line\n\nseparate_line(delimiter_left=\"(\", separator_symbol=\"*\")\n```\nThis will print:\n![img_8.png](Images/SeparatorPreview.png)\nIt looks pretty bad, but remember making a preset is recommended for most cases.\n\n# Contributing\nThanks for considering contributing to Fancy Print. You can read Contributing.md for further information!\n\n\u003chr\u003e\nRemember to keep your apps fancy ;)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammu%2Ffancy-print","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiammu%2Ffancy-print","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammu%2Ffancy-print/lists"}