我想在python的for tkMessageBox.showinfo()中实现Tkinter循环
我需要在框中打印一个list of lists。
我目前拥有的是:
tkMessageBox.showinfo(
"Help INFORMATION",
"help1 help2 \n help3 help4 \n help5 help6"
)
我想要的是:
像下面这样。
my_list=[['help1','help2'],['help3','help4'],['help5','help6']]
tkMessageBox.showinfo(
"Help INFORMATION",
for i in my_list:
i + "\n" #cant use print as I want to display it in the dialog box and not in the console.
)
这样对话框中的输出应如下所示:
help1 help2
help3 help4
help5 help6
但是我得到的是:
Syntax Error -> for i in my_list:
python大神给出的解决方案
这个怎么样:
my_list=[['help1','help2'],['help3','help4'],['help5','help6']]
tkMessageBox.showinfo(
"Help INFORMATION",
'\n'.join(map(' '.join, my_list))
)
我没有测试它,但理想情况下应该完成这项工作。