我不能使用for循环制作多个标签

时间:2019-04-09 08:34:03

标签: python tkinter

我希望标签中带有“ _”的数字等于随机生成的单词中字母的数量,但仅显示最后一个下划线。难道我做错了什么?有人可以帮忙吗?

def play ():
    word = random.choice (list1)
    print (word)
    list2 = list (word)
    print (list2)
    x_position = 10
    for i in list2:
        lbl = Label (root, text = '_')
        lbl.place (y = 10, x = x_position)
        x_position = x_position + 5

1 个答案:

答案 0 :(得分:0)

lbl = Label (root, text = '_')
lbl.pack()
lbl.place (y = 10, x = x_position)