Closed theduckchannel closed 3 years ago
choices
is supposed to be either a list of the choices, or a list of dictionaries. You have a list of tuples. Is your intent that the first value be what is presented to the user, and the second be what is returned? If so, change this:
[('index: [0] [amdgpu] current temp: 47.0°', 0), ('index: [1] [k10temp] current temp: 47.75°', 1)]
to
[{"name": "index: [0] [amdgpu] current temp: 47.0°", "value": 0}, {"name": "index: [1] [k10temp] current temp: 47.75°", "value": 1}]
Relevant documentation (admittedly it is a bit thin):
choices: (Array|Function) Choices array or a function returning a choices array. If defined as a function, the first parameter will be the current inquirer session answers. Array values can be simple strings, or objects containing a name (to display in list), a value (to save in the answers hash) and a short (to display after selection) properties. The choices array can also contain a Separator.
{
'type': 'expand',
'name': 'toppings',
'message': 'What about the toppings?',
'choices': [
{
'key': 'p',
'name': 'Pepperoni and cheese',
'value': 'PepperoniCheese'
},
{
'key': 'a',
'name': 'All dressed',
'value': 'alldressed'
},
{
'key': 'w',
'name': 'Hawaiian',
'value': 'hawaiian'
}
]
},
Hi,
I need create choice with (label, value) i write this: ` sensors = psutil.sensors_temperatures() tempUserChoices = [] for i, key in enumerate(sensors): tempUserChoices.append(( f'index: [{i}] [{key}] current temp: {sensors[key][i].current}°', i ))
`
And i got following error.
Whats are wrong? How to i return the value ?