menuchoice


Namemenuchoice JSON
Version 0.11 PyPI version JSON
download
home_pagehttps://github.com/xyzpw/menuchoice/
SummaryA terminal-based interactive menu selector which is controlled via arrow keys.
upload_time2024-08-03 14:11:47
maintainerxyzpw
docs_urlNone
authorxyzpw
requires_pythonNone
licenseMIT
keywords menu selector item selector ansi
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # menuchoice
![Pepy Total Downlods](https://img.shields.io/pepy/dt/menuchoice)
![GitHub repo size](https://img.shields.io/github/repo-size/xyzpw/menuchoice)
![PyPi - Version](https://img.shields.io/pypi/v/menuchoice)

**menuchoice** is a terminal-based menu selector with different menu styles and features.

![menuchoice-demo2](https://github.com/xyzpw/menuchoice/assets/76017734/c3ca060d-0c39-47be-9173-fa0d415a20b9)

## Usage
Creating a selection menu:
```python
import menuchoice
menu = menuchoice.MenuSelector(items=[
    "Hip-hop",
    "Rock",
    "Pop",
    "Country",
    "EDM",
], title="Most Streamed Music USA", description="Select a genre of music.")
```
> [!TIP]
> items can be given brief descriptions if they are type dictionary: `{"option": "brief description"}`

### Arrow Selection
Arrow select will display an arrow which can be moved up/down with the arrow keys:
```python
menu.arrow_select()
```
Output upon selection:
```python
[(4, "EDM")]
```

Additionally, multiple options can be selected:
```python
# no less than 2, no more than 3
menu.arrow_select(max_items=(2, 3))
# Adds an option to select all items
menu.arrow_select(allow_all=True)
```
Output:
```python
[(4, "EDM"), (1, "Rock")]
```

### Highlight Selecting
Highlight menus introduce the ability to have multiple pages (this is optional):
```python
menu.highlight_select(pages=[[0, 1, 2], [3, 4]])
```

The above code will create two pages, the first page contains the first three options, the second contains the last two options.<br>
To switch between these pages, use the left/right arrow keys.

The highlight menu can also disable options:
```python
menu.highlight_select(disabled_items=[3])
```
This code above will prevent the user from selecting index 3 of the menus items (the fourth option).

### Modifying Options
Menu selector items can have multiple options which can be navigated through with left/right arrow keys.

```python
menu.modify_select(options=[(0, "second option", "third option")])
```
This will allow the user to use left/right arrow keys to navigate through 3 different options for a single item's line.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/xyzpw/menuchoice/",
    "name": "menuchoice",
    "maintainer": "xyzpw",
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "menu selector, item selector, ansi",
    "author": "xyzpw",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/40/a4/669a3e112e142dcca401f7a995481de2b37a108181be0ef71b3bf0fea749/menuchoice-0.11.tar.gz",
    "platform": null,
    "description": "# menuchoice\n![Pepy Total Downlods](https://img.shields.io/pepy/dt/menuchoice)\n![GitHub repo size](https://img.shields.io/github/repo-size/xyzpw/menuchoice)\n![PyPi - Version](https://img.shields.io/pypi/v/menuchoice)\n\n**menuchoice** is a terminal-based menu selector with different menu styles and features.\n\n![menuchoice-demo2](https://github.com/xyzpw/menuchoice/assets/76017734/c3ca060d-0c39-47be-9173-fa0d415a20b9)\n\n## Usage\nCreating a selection menu:\n```python\nimport menuchoice\nmenu = menuchoice.MenuSelector(items=[\n    \"Hip-hop\",\n    \"Rock\",\n    \"Pop\",\n    \"Country\",\n    \"EDM\",\n], title=\"Most Streamed Music USA\", description=\"Select a genre of music.\")\n```\n> [!TIP]\n> items can be given brief descriptions if they are type dictionary: `{\"option\": \"brief description\"}`\n\n### Arrow Selection\nArrow select will display an arrow which can be moved up/down with the arrow keys:\n```python\nmenu.arrow_select()\n```\nOutput upon selection:\n```python\n[(4, \"EDM\")]\n```\n\nAdditionally, multiple options can be selected:\n```python\n# no less than 2, no more than 3\nmenu.arrow_select(max_items=(2, 3))\n# Adds an option to select all items\nmenu.arrow_select(allow_all=True)\n```\nOutput:\n```python\n[(4, \"EDM\"), (1, \"Rock\")]\n```\n\n### Highlight Selecting\nHighlight menus introduce the ability to have multiple pages (this is optional):\n```python\nmenu.highlight_select(pages=[[0, 1, 2], [3, 4]])\n```\n\nThe above code will create two pages, the first page contains the first three options, the second contains the last two options.<br>\nTo switch between these pages, use the left/right arrow keys.\n\nThe highlight menu can also disable options:\n```python\nmenu.highlight_select(disabled_items=[3])\n```\nThis code above will prevent the user from selecting index 3 of the menus items (the fourth option).\n\n### Modifying Options\nMenu selector items can have multiple options which can be navigated through with left/right arrow keys.\n\n```python\nmenu.modify_select(options=[(0, \"second option\", \"third option\")])\n```\nThis will allow the user to use left/right arrow keys to navigate through 3 different options for a single item's line.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A terminal-based interactive menu selector which is controlled via arrow keys.",
    "version": "0.11",
    "project_urls": {
        "Homepage": "https://github.com/xyzpw/menuchoice/"
    },
    "split_keywords": [
        "menu selector",
        " item selector",
        " ansi"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd48dd7aa7df09382ac71ffc56138f2f8c4a024c6a6e7045ffc11f2f3d5e5d75",
                "md5": "0201e221b4831a0ba22f0be950053b32",
                "sha256": "443a0f30fe7b4b6f631cbbacbd821c4e27648fe5155cd144549dee6505b5c459"
            },
            "downloads": -1,
            "filename": "menuchoice-0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0201e221b4831a0ba22f0be950053b32",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8705,
            "upload_time": "2024-08-03T14:11:46",
            "upload_time_iso_8601": "2024-08-03T14:11:46.520172Z",
            "url": "https://files.pythonhosted.org/packages/fd/48/dd7aa7df09382ac71ffc56138f2f8c4a024c6a6e7045ffc11f2f3d5e5d75/menuchoice-0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "40a4669a3e112e142dcca401f7a995481de2b37a108181be0ef71b3bf0fea749",
                "md5": "59505c5324feaf6935e64ef3de74f047",
                "sha256": "1a3a5d1f518dc64a6c06ac414b410cfb73c706f65e4df7bc073351029903c3c5"
            },
            "downloads": -1,
            "filename": "menuchoice-0.11.tar.gz",
            "has_sig": false,
            "md5_digest": "59505c5324feaf6935e64ef3de74f047",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8681,
            "upload_time": "2024-08-03T14:11:47",
            "upload_time_iso_8601": "2024-08-03T14:11:47.865018Z",
            "url": "https://files.pythonhosted.org/packages/40/a4/669a3e112e142dcca401f7a995481de2b37a108181be0ef71b3bf0fea749/menuchoice-0.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-03 14:11:47",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "xyzpw",
    "github_project": "menuchoice",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "menuchoice"
}
        
Elapsed time: 1.90712s