用于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


支持的操作系统

OSSupport
UnixX
LinuxX
MacOSXX
Windows

支持的Python版本

^{tb2}$

Python包依赖性
  • 无依赖关系
VersionLibraryinstallation
NoneNoneNone

许可证

这个项目是在MIT许可下授权的-请参阅LICENSE文件了解详细信息

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java InputStream对象在声明后关闭   java未定义名为“transactionManager”的bean重命名transactionManager   java“jar”命令何时会拒绝将类添加到java中。jar文件?   java JPA标准依赖WHERE子句   安卓中从SD卡读取文本文件时出现java错误   java直接启用类似位置的权限   使用@WebMvcTest和Mockito-BDDMockito对SpringBoot-RestController进行java测试   java JSESSIONID存储在哪里?   java jtextarea鼠标事件覆盖容器鼠标事件   java DRL无法解析动态加载的类   java是从一个方法返回多个对象的最简单方法   java自定义按钮/编辑框是否不可见?   java GUI如何在保存用户输入的同时在面板或框架之间切换   swing Java自定义JSlider不会更新   GridBagLayout中的java超过1个JPanel   java从ProjectReactor中的flux中采样除第一个元素外的所有元素   Java泛型和泛型类型   Java代码生成宽指令的jvm