Python 在TKinter中使用for循环打印列表
我想在单击按钮时使用for循环将列表中的每个项目打印为TKinter标签。下面是我的代码,但是它没有输出任何东西 我正在寻找的结果是,在第一个实例中,标签应打印“111111”,在下一个实例中,标签应打印“22222”Python 在TKinter中使用for循环打印列表,python,tkinter,Python,Tkinter,我想在单击按钮时使用for循环将列表中的每个项目打印为TKinter标签。下面是我的代码,但是它没有输出任何东西 我正在寻找的结果是,在第一个实例中,标签应打印“111111”,在下一个实例中,标签应打印“22222” 关于我如何做到这一点,或者我做错了什么,你有什么想法吗?你得说出来l1.pack()@tobias_k谢谢你指出这一点,显然没有提到这一点。工作如所愿! from tkinter import * def get_searchid(): search_id = ["11
关于我如何做到这一点,或者我做错了什么,你有什么想法吗?你得说出来
l1.pack()
@tobias_k谢谢你指出这一点,显然没有提到这一点。工作如所愿!
from tkinter import *
def get_searchid():
search_id = ["1111111",'222222']
for search in search_id:
l1 = Label(root, text=search)
l1.pack
root = Tk()
button1 = Button(root, text="Search Me", command=get_searchid)
button1.place(x=50, y=50)
button1.pack
root.mainloop()