我有一些图像列表,我正试图将它们随机显示在标签中。但是,我只能看到应在图像上放置“标签”的背景颜色。这是我的代码。
import random
import time
from tkinter import *
wn=Tk()
wn.geometry("500x300")
def displayPic():
list1 = ["pic1.png", "pic2.png", "pic3.png", "pic4.png", "pic5.png", "pic6.png"]
myPic = random.choice(list1)
imag1 = PhotoImage(file="pic1.png")# here is where ı confuse..
lb1 = Label(wn, bg="pink", text="", image=imag1)
lb1.place(x=100, y=10)
wn.after(1000, displayPic)
btn1 = Button(text="SHOWme",command=displayPic)
btn1.place(x=100,y=200)
wn.mainloop()