python-cli-menu


Namepython-cli-menu JSON
Version 1.8 PyPI version JSON
download
home_pagehttps://github.com/MathisJANKOVIC/py-cli-menu
SummaryA simple cross-platform module to create pretty menu in console
upload_time2024-01-23 10:37:37
maintainer
docs_urlNone
authorRasting (Mathis Jankovic)
requires_python
licenseMIT
keywords python menu console cli command line
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            `python-cli-menu` is a simple cross-plateform Python module that allows you to easilly create pretty custom menus in console. Customize the title, options, every colors and initial cursor position as you wish. Use arrows keys to navigate through the menu and enter key to select an option.

## Quickstart

```python
def menu(
    title: str | Sequence[str],
    options: list[str] | tuple[str, ...],
    cursor_color: str | tuple[int, int, int],
    title_color: (
        str | tuple[int, int, int] | None |
        Sequence[str | tuple[int, int, int] | None]
    ) = None,
    options_color: (
        str | tuple[int, int, int] | None |
        Sequence[str | tuple[int, int, int] | None]
    ) = None,
    initial_cursor_position: str | int = 0,
) -> str:
```
> Creates a pretty menu in console with arrow key navigation and returns the selected option. Clears console once an option is selected.

- `title` is the main title of the menu, can be displayed on multiple lines if a list or a tuple is passed.
- `options` is the list of actions or choices that can be selected.
- `cursor_color` is the color of the cursor, available colors are `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`
                and their lighter versions (e.g. `light_red`), use custom color by providing a tuple containing color RGB values.
- `title_color` is the color of the title, available colors are the same as `cursor_color`, customize the color of each line by providing a list of colors,
                each color will be associated with the line of the corresponding index (default color is terminal text color).
- `options_color` is the color of options, available colors are the same as `cursor_color`, customize every option color by providing a list of colors,
                each color will be associated with the option of the corresponding index (default color is terminal text color).
- `initial_cursor_position` is the option or the index of the option where the initial cursor position is set (default position is first element).

<label style="font-size: 15px;">Examples :</label>

```python
from pythonclimenu import menu

OPTIONS = ["Option 1", "Option 2", "Option 3", "Quit"]

# Creates a simple console menu with blue cursor
menu1 = menu(title="Amazing Console Menu", options=OPTIONS, cursor_color="blue")

menu2 = menu(
    title = ["Amazing Console", "Menu"], # displays title on multiple lines
    options = OPTIONS,
    cursor_color = (255, 95, 46), # sets the cursor color using RGB values
    title_color = [
        "blue", # colors "Amazing Console"
        "light_red" # colors "Menu"
    ],
    initial_cursor_position = -1 # sets cursor default position to 'Quit'
)

menu3 = menu(
    title = ["Amazing Console", "Menu"], # displays title on multiple lines
    options = OPTIONS,
    cursor_color = "yellow",
    title_color = "light_green", # colors all lines of title
    options_color = [
        "magenta", # colors options[0]
        "light_cyan", # colors options[1]
        (192, 11, 168) # colors options[2]
        # option[3] color is not specifed so it will be considered as None
    ],
    initial_cursor_position = OPTIONS[1] # sets cursor default position to 'Option 1'
)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MathisJANKOVIC/py-cli-menu",
    "name": "python-cli-menu",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "python,menu,console,cli,command,line",
    "author": "Rasting (Mathis Jankovic)",
    "author_email": "mathis.jankovic@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f8/83/280c3f9754dd2411ddd194161bc7930f45ca5ed1d1488dc330a6bc77d944/python-cli-menu-1.8.tar.gz",
    "platform": null,
    "description": "`python-cli-menu` is a simple cross-plateform Python module that allows you to easilly create pretty custom menus in console. Customize the title, options, every colors and initial cursor position as you wish. Use arrows keys to navigate through the menu and enter key to select an option.\r\n\r\n## Quickstart\r\n\r\n```python\r\ndef menu(\r\n    title: str | Sequence[str],\r\n    options: list[str] | tuple[str, ...],\r\n    cursor_color: str | tuple[int, int, int],\r\n    title_color: (\r\n        str | tuple[int, int, int] | None |\r\n        Sequence[str | tuple[int, int, int] | None]\r\n    ) = None,\r\n    options_color: (\r\n        str | tuple[int, int, int] | None |\r\n        Sequence[str | tuple[int, int, int] | None]\r\n    ) = None,\r\n    initial_cursor_position: str | int = 0,\r\n) -> str:\r\n```\r\n> Creates a pretty menu in console with arrow key navigation and returns the selected option. Clears console once an option is selected.\r\n\r\n- `title` is the main title of the menu, can be displayed on multiple lines if a list or a tuple is passed.\r\n- `options` is the list of actions or choices that can be selected.\r\n- `cursor_color` is the color of the cursor, available colors are `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`\r\n                and their lighter versions (e.g. `light_red`), use custom color by providing a tuple containing color RGB values.\r\n- `title_color` is the color of the title, available colors are the same as `cursor_color`, customize the color of each line by providing a list of colors,\r\n                each color will be associated with the line of the corresponding index (default color is terminal text color).\r\n- `options_color` is the color of options, available colors are the same as `cursor_color`, customize every option color by providing a list of colors,\r\n                each color will be associated with the option of the corresponding index (default color is terminal text color).\r\n- `initial_cursor_position` is the option or the index of the option where the initial cursor position is set (default position is first element).\r\n\r\n<label style=\"font-size: 15px;\">Examples :</label>\r\n\r\n```python\r\nfrom pythonclimenu import menu\r\n\r\nOPTIONS = [\"Option 1\", \"Option 2\", \"Option 3\", \"Quit\"]\r\n\r\n# Creates a simple console menu with blue cursor\r\nmenu1 = menu(title=\"Amazing Console Menu\", options=OPTIONS, cursor_color=\"blue\")\r\n\r\nmenu2 = menu(\r\n    title = [\"Amazing Console\", \"Menu\"], # displays title on multiple lines\r\n    options = OPTIONS,\r\n    cursor_color = (255, 95, 46), # sets the cursor color using RGB values\r\n    title_color = [\r\n        \"blue\", # colors \"Amazing Console\"\r\n        \"light_red\" # colors \"Menu\"\r\n    ],\r\n    initial_cursor_position = -1 # sets cursor default position to 'Quit'\r\n)\r\n\r\nmenu3 = menu(\r\n    title = [\"Amazing Console\", \"Menu\"], # displays title on multiple lines\r\n    options = OPTIONS,\r\n    cursor_color = \"yellow\",\r\n    title_color = \"light_green\", # colors all lines of title\r\n    options_color = [\r\n        \"magenta\", # colors options[0]\r\n        \"light_cyan\", # colors options[1]\r\n        (192, 11, 168) # colors options[2]\r\n        # option[3] color is not specifed so it will be considered as None\r\n    ],\r\n    initial_cursor_position = OPTIONS[1] # sets cursor default position to 'Option 1'\r\n)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple cross-platform module to create pretty menu in console",
    "version": "1.8",
    "project_urls": {
        "Homepage": "https://github.com/MathisJANKOVIC/py-cli-menu"
    },
    "split_keywords": [
        "python",
        "menu",
        "console",
        "cli",
        "command",
        "line"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f883280c3f9754dd2411ddd194161bc7930f45ca5ed1d1488dc330a6bc77d944",
                "md5": "b4f08cf54e0ec4d472d8bdca9e178995",
                "sha256": "ece0549573191420d354e200e4db9567957630f5055682b091493d3b2ebac4b8"
            },
            "downloads": -1,
            "filename": "python-cli-menu-1.8.tar.gz",
            "has_sig": false,
            "md5_digest": "b4f08cf54e0ec4d472d8bdca9e178995",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6322,
            "upload_time": "2024-01-23T10:37:37",
            "upload_time_iso_8601": "2024-01-23T10:37:37.571545Z",
            "url": "https://files.pythonhosted.org/packages/f8/83/280c3f9754dd2411ddd194161bc7930f45ca5ed1d1488dc330a6bc77d944/python-cli-menu-1.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-23 10:37:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MathisJANKOVIC",
    "github_project": "py-cli-menu",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "python-cli-menu"
}
        
Elapsed time: 0.38233s