简体   繁体   English

tkinter.messagebox中的“ For”循环?

[英]“For” loops within a tkinter.messagebox?

Here is the offending code: 这是有问题的代码:

import itertools

perms = itertools.product('AEIOU', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '-', '0123456789', '0123456789', '0123456789')

print('The possible combinations are:')
for perm in perms:
    print(''.join(perm))

I am wanting to actually display this generated information in a GUI tkinter box, a small function within a program that has various other functions. 我想实际在GUI tkinter框中显示此生成的信息,GUI tkinter框中是具有各种其他功能的程序中的一个小功能。 I tried: 我试过了:

for perm in perms:
        tkinter.messagebox.showinfo('Results', \
        ''.join(perm))

...but this displays each possibility, one by one, each in invidivual windows. ...但是这会在个人窗口中逐一显示每种可能性。 Is it possible to have the for loop function within the window, so it scrolls in the window? 窗口内是否可能有for循环功能,因此它会在窗口中滚动? If not, is there a friendlier solution I should research to displaying all this info in a clean way? 如果没有,我是否应该研究一种更友好的解决方案以干净的方式显示所有这些信息?

I think you just need to move your loop in a little bit. 我认为您只需要稍微移动一下循环即可。 This ought to do it: 这应该做到:

tkinter.messagebox.showinfo('Results', '\n'.join(''.join(perm) for perm in perms))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM