I am new to Python 2.7 but I was wondering if it is possible to have checkboxes that are selectable by a user via the command line.
The only example I know of is yeoman (below) but its probably not written in Python.
Thank You
Have a look at the python-inquirer package.
To make a checkbox list you can do something like this:
import inquirer
questions = [inquirer.Checkbox(
'interests',
message="What are you interested in?",
choices=['Computers', 'Books', 'Science', 'Nature', 'Fantasy', 'History'],
)]
answers = inquirer.prompt(questions) # returns a dict
print(answers['interests'])
There is beaupy , which allows you to do something like this:
from beaupy import select_multiple
pizza_toppings = select_mutliple(['pineapple', 'olives', 'anchovies', 'mozzarella', 'parma ham']
maximal_count=3,
minimal_count=1)
Note: I am a maintainer of beaupy
and this is nothing short of shameless self-promotion.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.