Name | PyConsoleMenu2 JSON |
Version |
1.2.0
JSON |
| download |
home_page | None |
Summary | An extreamly easy to use Python console menu |
upload_time | 2024-09-21 12:48:05 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.7 |
license | None |
keywords |
console
menu
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# PyConsoleMenu2
An extreamly easy to use Python console menu. (fork ver.)
Features:
- Cross platform, interactive selection
- Flexible Builder pattern
- Multi selection and Callback selection support
## Preview
![Selector](https://github.com/BaggerFast/PyConsoleMenu/blob/main/assets/selector.gif?raw=true)
[See other](https://github.com/BaggerFast/PyConsoleMenu/tree/main/assets)
## Installation 💾
```sh
pip install PyConsoleMenu2
```
## Usage example 👨💻
```py
from PyConsoleMenu2 import BaseMenu, ItemMenu, MultiMenu
# basic usage, get the index
ret = BaseMenu("title: BaseMenu").add_options(["a", "b", "c"]).run()
print(ret) # 0 / 1 / 2
# get the name, and more options
ret = (
BaseMenu("title: BaseMenu")
.add_options(["a", "b", "c"])
.add_option("d")
.default_index(1)
.prefix("[")
.suffix("]")
.raise_when_too_small()
.on_user_cancel(lambda: print("cancel"))
.run_get_item()
)
print(ret) # a / b / c / d
# multi selection (use space to select)
ret = MultiMenu("title: MultiMenu").max_count(2).add_options(["a", "b", "c"]).run()
print(ret)
# each option related to an item. could be used as callback function.
func = (
ItemMenu("title: ItemMenu")
.add_option("a", lambda: print("a"))
.add_options([("b", lambda: print("b")), ("c", lambda: print("c"))])
.run_get_item()
)
func()
```
~~_[See more examples](https://github.com/lxl66566/PyConsoleMenu/tree/main/examples)_~~
## Document
- Three types of menus: _BaseMenu_ (only strings), _MultiMenu_ (multi selections), _ItemMenu_ (binds items to each option)
- Keybindings: [See code](./PyConsoleMenu2/utils.py)
- methods:
- `run`: get index of selected option.
- `run_get_item`: get the related item of selected option. Option string for _BaseMenu_, a set of string for _MultiMenu_, and user given item for _ItemMenu_.
- `raise_when_too_small`: when set to True, raise a `error.RenderException`, otherwise ignore drawing.
- `on_user_cancel`: exec a function when user cancel the input. If not set, raise `KeyboardInterrupt` by default.
- ...
## Additional
There's problem when displaying CJK string on windows terminal, caused by upstream dependency [windows-curses](https://github.com/zephyrproject-rtos/windows-curses). But still usable.
Raw data
{
"_id": null,
"home_page": null,
"name": "PyConsoleMenu2",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": null,
"keywords": "console, menu",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/33/19/fe54fbf648847f8b73f067f59fcba06cc164665c3933d82edb49c4d56f3e/pyconsolemenu2-1.2.0.tar.gz",
"platform": null,
"description": "# PyConsoleMenu2\n\nAn extreamly easy to use Python console menu. (fork ver.)\n\nFeatures:\n\n- Cross platform, interactive selection\n- Flexible Builder pattern\n- Multi selection and Callback selection support\n\n## Preview\n\n![Selector](https://github.com/BaggerFast/PyConsoleMenu/blob/main/assets/selector.gif?raw=true)\n\n[See other](https://github.com/BaggerFast/PyConsoleMenu/tree/main/assets)\n\n## Installation \ud83d\udcbe\n\n```sh\npip install PyConsoleMenu2\n```\n\n## Usage example \ud83d\udc68\u200d\ud83d\udcbb\n\n```py\nfrom PyConsoleMenu2 import BaseMenu, ItemMenu, MultiMenu\n\n# basic usage, get the index\nret = BaseMenu(\"title: BaseMenu\").add_options([\"a\", \"b\", \"c\"]).run()\nprint(ret) # 0 / 1 / 2\n\n# get the name, and more options\nret = (\n BaseMenu(\"title: BaseMenu\")\n .add_options([\"a\", \"b\", \"c\"])\n .add_option(\"d\")\n .default_index(1)\n .prefix(\"[\")\n .suffix(\"]\")\n .raise_when_too_small()\n .on_user_cancel(lambda: print(\"cancel\"))\n .run_get_item()\n)\nprint(ret) # a / b / c / d\n\n# multi selection (use space to select)\nret = MultiMenu(\"title: MultiMenu\").max_count(2).add_options([\"a\", \"b\", \"c\"]).run()\nprint(ret)\n\n# each option related to an item. could be used as callback function.\nfunc = (\n ItemMenu(\"title: ItemMenu\")\n .add_option(\"a\", lambda: print(\"a\"))\n .add_options([(\"b\", lambda: print(\"b\")), (\"c\", lambda: print(\"c\"))])\n .run_get_item()\n)\nfunc()\n```\n\n~~_[See more examples](https://github.com/lxl66566/PyConsoleMenu/tree/main/examples)_~~\n\n## Document\n\n- Three types of menus: _BaseMenu_ (only strings), _MultiMenu_ (multi selections), _ItemMenu_ (binds items to each option)\n- Keybindings: [See code](./PyConsoleMenu2/utils.py)\n- methods:\n - `run`: get index of selected option.\n - `run_get_item`: get the related item of selected option. Option string for _BaseMenu_, a set of string for _MultiMenu_, and user given item for _ItemMenu_.\n - `raise_when_too_small`: when set to True, raise a `error.RenderException`, otherwise ignore drawing.\n - `on_user_cancel`: exec a function when user cancel the input. If not set, raise `KeyboardInterrupt` by default.\n - ...\n\n## Additional\n\nThere's problem when displaying CJK string on windows terminal, caused by upstream dependency [windows-curses](https://github.com/zephyrproject-rtos/windows-curses). But still usable.\n",
"bugtrack_url": null,
"license": null,
"summary": "An extreamly easy to use Python console menu",
"version": "1.2.0",
"project_urls": {
"Homepage": "https://github.com/lxl66566/PyConsoleMenu2",
"Repository": "https://github.com/lxl66566/PyConsoleMenu2.git"
},
"split_keywords": [
"console",
" menu"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "579431f9d8892fddd0cbb9646d3c7858b98ed951108ca2eb6780132348afea49",
"md5": "1065632b6d95038827c7479db3621ec9",
"sha256": "a199a11e4f34ad75168a4590911de59f7f10fb87eb8974f766c9bdd7f5e2eef8"
},
"downloads": -1,
"filename": "pyconsolemenu2-1.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1065632b6d95038827c7479db3621ec9",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6688,
"upload_time": "2024-09-21T12:48:04",
"upload_time_iso_8601": "2024-09-21T12:48:04.439483Z",
"url": "https://files.pythonhosted.org/packages/57/94/31f9d8892fddd0cbb9646d3c7858b98ed951108ca2eb6780132348afea49/pyconsolemenu2-1.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3319fe54fbf648847f8b73f067f59fcba06cc164665c3933d82edb49c4d56f3e",
"md5": "8d0ded7e8523adc7e47a0e2678f6ad8e",
"sha256": "1934cbaacb2d00bac955db85f88a1c77757613fd17b9c7ca6f8d017aac08113e"
},
"downloads": -1,
"filename": "pyconsolemenu2-1.2.0.tar.gz",
"has_sig": false,
"md5_digest": "8d0ded7e8523adc7e47a0e2678f6ad8e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 8038,
"upload_time": "2024-09-21T12:48:05",
"upload_time_iso_8601": "2024-09-21T12:48:05.987017Z",
"url": "https://files.pythonhosted.org/packages/33/19/fe54fbf648847f8b73f067f59fcba06cc164665c3933d82edb49c4d56f3e/pyconsolemenu2-1.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-21 12:48:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lxl66566",
"github_project": "PyConsoleMenu2",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"lcname": "pyconsolemenu2"
}