所以我尝试使用for循环在10个tkinterLabel
上动态打印列表中的项。目前我有以下代码:
labe11 = StringVar()
list2_placer = 0
list1_placer = 1
mover = 227
for items in range(10):
item_values = str(list1[list1_placer] + " " +list2[list2_placer])
Label(canvas1, width="100", height="2",textvariable=labe11).place(x=200,y=mover)
labe11.set(item_values)
list1_placer = list1_placer +1
list2_placer = list2_placer +1
mover = mover +50
其中list1
和list2
是包含来自单独函数的字符串或整数的列表,它们有10个以上的项,只需要前10个。在
目前,这只是打印列表中的最后一项在10个单独的标签上。 提前谢谢!在
只需为每个
Label
使用不同的StringVar
。目前,您只需将同一个传递给所有标签,所以当您更新它时,它们都会一起更新。在这里有一个例子。你没有给出一个完全可运行的程序,所以我不得不填补空白。在
相关问题 更多 >
编程相关推荐