Ich hätte gerne eine Liste der verbundenen Benutzer, habe Dialog tui dafür gewählt. Dies ist mein erstes kleines Python (3.5) Skript.Wie übergibt man eine Variable an die Auswahlmöglichkeiten des Dialoges?
import sys
import psutil
import locale
import dialog
import pprint
locale.setlocale(locale.LC_ALL, '')
d = dialog.Dialog(dialog="dialog")
choices = []
i = 0;
users = psutil.users()
for user in users:
item = ('{0}.'.format(i), user.name)
choices.append(item)
i += 1
choices.append(('X', "Exit"))
#pprint.pprint(choices)
#OUTPUT: [('0.', 'root'), ('1.', 'root'), ('X', 'Exit')]
#code, tag = d.menu("List", choices)
code, tag = d.menu("List", choices=[('0.', 'root'), ('1.', 'root'), ('X', 'Exit')])
Meine Frage ist, warum ist das Dialog Arbeiten mit den Entscheidungen inline definiert, kann aber nicht, wenn ich nur geben, die bereits Liste definiert, die auf der Liste, die in der Inline-Definition identisch ist.
child_output.strip()))
dialog.DialogError: dialog-like terminated due to an error: the dialog-like program exited with status 3 (which was passed to it as the DIALOG_ERROR environment variable). Sometimes, the reason is simply that dialog was given a height or width parameter that is too big for the terminal in use. Its output, with leading and trailing whitespace stripped, was:
Error: Expected at least 6 tokens for --menu, have 4.