我在 python 中做一个图片查看器,代码是这样的
def walk(dirname):
res = []
for name in os.listdir(dirname):
path = os.path.join(dirname, name)
if os.path.isfile(path):
res.append(path)
else:
walk(path)
return res
images = walk("images")
def show_image(filename):
image = PIL.open(filename)
image = image.resize((120, 120))
photo = ImageTk.PhotoImage(image)
label = Label(image=photo)
label.image = photo
label.pack()
for i in images:
show_image(i)
此代码有效,但将图像显示在一个块中,我想显示标签内联的东西,例如在 html 中
<div style="display:inline><img src="photo"></div>
怎么能做到呢?