我想在窗口的目录中显示多个图像
但根据这段代码,一次只能显示一个图像
这是我的密码:
base = Tk()
base.geometry('1000x1000')
folder_selected = filedialog.askdirectory()
txtfiles = []
for file in glob.glob(str(folder_selected) + "/*.jpg"):
txtfiles.append(file)
a = 10
def createIMG():
global a, img
for location in txtfiles:
n = Label(base, text='asd')
n.place(x=a, y=10)
img = Image.open(location)
img = img.resize((250, 250))
img = ImageTk.PhotoImage(img)
panel = Label(base, image=img)
panel.place(x=a,y=10)
a = a + 200
createIMG()
# threading.Thread(target=createIMG).start()
mainloop()
我以为这很容易,但花了很长时间才弄明白。您需要一个容器来存放所有需要的图像
.open()
相关问题 更多 >
编程相关推荐