你必须定义你的新主题,并将其作为参数传递给
inquirer.prompt
。
以下是修改后的代码,将“X”更改为“Y”,将“o”更改为为“N”:
import os
import sys
from pprint import pprint
import yaml
from inquirer.themes import Default
sys.path.append(os.path.realpath("."))
import inquirer # noqa
questions = [
inquirer.Checkbox(
"interests",
message="What are you interested in?",
choices=["Computers", "Books", "Science", "Nature", "Fantasy", "History"],
default=["Computers", "Books"],
),
]
class WorkplaceFriendlyTheme(Default):
"""Custom theme replacing X with Y and o with N"""
def __init__(self):
super().__init__()
self.Checkbox.selected_icon = "Y"
self.Checkbox.unselected_icon = "N"
answers = inquirer.prompt(questions, theme=WorkplaceFriendlyTheme())
pprint(answers)
print(yaml.dump(answers))