0

The sample script:

import os
import sys
from pprint import pprint
import yaml

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"],
    ),
]

answers = inquirer.prompt(questions)

pprint(answers)
print(yaml.dump(answers))

produces:

[?] What are you interested in?: 
   X Computers
   o Books

How do I change "X" and "o" to "Y" and "N" respectively?

PS: It's pretty common knowledge that XOXO means "hugs and kisses", so it may not be appropriate in some working environments.

puravidaso
  • 1,013
  • 1
  • 5
  • 22

1 Answers1

1

You have to define Your new theme and pass it as a parameter to inquirer.prompt.

Here is modified code changing "X" to "Y" and "o" to "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))
Domarm
  • 2,360
  • 1
  • 5
  • 17
  • 1
    You must have read the source code, as I have read the documentation but could not find a configuration parameter to pass to the module. There should be. Care to send a patch? Thanks! – puravidaso Feb 07 '22 at 23:35
  • I've just checked input parameters for `prompt` and checked how theme class looks like. They have only documentation for set of things, not everything. Feel free to let them know, that this is important and should be part of documentation. – Domarm Feb 08 '22 at 05:53