用于python的控制台单/多选择器。
cselector的Python项目详细描述
https://github.com/aieater/python_console_selector
C选择器(控制台选择器)
说明
python的控制台选择器。 这是受https://pypi.org/project/pick/的启发,它想为iTerm2(imgcat)中的图像预览器进行更多的定制。在
单选择器
Title hoge hoge.
=> ItemA
ItemB
ItemC
多选择器
^{pr2}$二进制选择器
Do you do machine learning? (default: yes)[Y/n] > Yes
# True
特点
- 单一选择器。在
- 多选择器。在
- 二进制选择器。在
- 没有依赖关系。在
- 无清晰显示。在
- 页面导航。在
- 所有选择器。在
- 图像查看器(专用)
安装
pip3 install cselector
单选择器
- Move:“向上”、“向下”键
- End:“Return”键
from cselector import selector
selected = selector(options=["ItemA","ItemB","ItemC"],title="Title hoge hoge.")
print(selected) # (<Index>,<Option>)
Title hoge hoge.
=> ItemA
ItemB
ItemC
多选择器
- Pagenation:“左”、“右”键
- Move:“向上”、“向下”键
- 选择:“空格”键
- End:“Return”键
- 预览:“@”键
from cselector import multi_selector
options = []
for x in range(47):
options.append("Item"+str(x))
selected_array = multi_selector(options=options,title="Title hogehoge")
print(selected_array) # [(<Index>,<Option>),(<Index>,<Option>),(<Index>,<Option>)....]
^{pr2}$
多选择器-带所有选择器
from cselector import multi_selector
options = []
for x in range(47):
options.append("Item"+str(x))
selected_array = multi_selector(options=options,title="Title hogehoge",all="All item title")
print(selected_array) # [(<Index>,<Option>),(<Index>,<Option>),(<Index>,<Option>)....]
Title hogehoge
[*] All item title
[*] Item0
[*] Item1
[*] Item2
[*] Item3
[*] Item4
[*] Item5
[*] Item6
[*] Item7
[*] Item8
1 2 3 4 5
多选择器-最小选择
from cselector import multi_selector
options = []
for x in range(47):
options.append("Item"+str(x))
selected_array = multi_selector(options=options,title="Title hogehoge",min_count=2)
print(selected_array) # [(<Index>,<Option>),(<Index>,<Option>),(<Index>,<Option>)....]
多选择器-页面的最大项目编号
from cselector import multi_selector
options = []
for x in range(47):
options.append("Item"+str(x))
selected_array = multi_selector(options=options,title="Title hogehoge",split=20)
print(selected_array) # [(<Index>,<Option>),(<Index>,<Option>),(<Index>,<Option>)....]
多选择器-带预览器(必需的aimage库)
- 预览:“@”键
import aimage
import glob
import os
from cselector import multi_selector
options = []
preview = []
for f in glob.glob(os.path.expanduser("~/cg/*.jpg")):
preview += [aimage.load(f)]
options += [os.path.basename(f)]
print(options)
selected_array = multi_selector(options=options,title="Title hogehoge",preview=preview,preview_console=True)
print(selected_array) # [(<Index>,<Option>),(<Index>,<Option>),(<Index>,<Option>)....]
二进制选择器-是或否
from cselector import yes_or_no
ret = yes_or_no(question="Do you do machine learning?",default="y")
print(ret) # True/False
支持的操作系统
OS | Support |
---|---|
Unix | X |
Linux | X |
MacOSX | X |
Windows |
支持的Python版本
^{tb2}$Python包依赖性
- 无依赖关系
Version | Library | installation |
---|---|---|
None | None | None |
许可证
这个项目是在MIT许可下授权的-请参阅LICENSE文件了解详细信息
- 项目
标签: