Skip to main content

Console single/multi selector for python.

Project description

https://github.com/aieater/python_console_selector

cselector (Console Selector)

Description

Console selector for python. This is inspired from https://pypi.org/project/pick/ and it wanted to more customize for image previewer in iTerm2(imgcat).

Single Selector
Title hoge hoge.
=>  ItemA
    ItemB
    ItemC
Multi Selector
Title hogehoge
[ ]  Item0
[ ]  Item1
[*]  Item2
[ ]  Item3
[ ]  Item4
[ ]  Item5
[ ]  Item6
[ ]  Item7
[*]  Item8
[ ]  Item9
1 2 3 4 5
Binary Selector
Do you do machine learning? (default: yes)[Y/n] > Yes
# True


Features

  • Single selector.
  • Multi selector.
  • Binary selector.
  • No dependencies.
  • No clear display.
  • Page navigation.
  • All selector.
  • Image viewer (for private)

Installation

pip3 install cselector



Single selector

  • Move: 'Up', 'Down' key
  • End: 'Return' key
from cselector import selector

selected = selector(options=["ItemA","ItemB","ItemC"],title="Title hoge hoge.")
print(selected) # (<Index>,<Option>)
Title hoge hoge.
=>  ItemA
    ItemB
    ItemC

Multi Selector

  • Pagenation: 'Left', 'Right' key
  • Move: 'Up', 'Down' key
  • Select: 'Space' key
  • End: 'Return' key
  • Preview: '@' key
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>)....]
Title hogehoge
[ ]  Item0
[ ]  Item1
[*]  Item2
[ ]  Item3
[ ]  Item4
[ ]  Item5
[ ]  Item6
[ ]  Item7
[*]  Item8
[ ]  Item9
1 2 3 4 5

Multi Selector - With all selector

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

Multi Selector - Minimum selection

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>)....]

Multi Selector - Maximum item number of page

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>)....]

Multi Selector - With previewer (Required aimage library)

  • Preview: '@' key
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>)....]

Binary selector - Yes or No

from cselector import yes_or_no
ret = yes_or_no(question="Do you do machine learning?",default="y")
print(ret) # True/False


Supported OS

OS Support
Unix
Linux
MacOSX
Windows

Supported Python Version

Version Support
Python2.7
Python3.4
Python3.5
Python3.6
Python3.7
Python3.8


Python package dependencies

  • No dependencies
Version Library installation
None None None

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for cselector, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size cselector-0.1.1.tar.gz (5.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page