0
私は接続されたユーザのリストを持っていますが、これのためにダイアログtuiを選択しました。 これは私の最初の小さなpython(3.5)スクリプトです。変数をダイアログの選択肢に渡すにはどうすればいいですか?
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')])
私の質問は、なぜな選択肢を持つダイアログ作品はインラインで定義されたということですが、 私はインライン定義に提供されたリストと同じです、すでに定義されたリストを与えることができないとき。
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.