Im doing a pictures viewer in python , the code is this
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)
this code works but show the images in a block one above other, i want to show the labels inline something like in html
<div style="display:inline><img src="photo"></div>
how can achieved that?
If you give the option side="left"
to the pack command, images will all appear in a single row. Is that what you want?
label.pack(side="left")
For more information about the pack command, see here: http://effbot.org/tkinterbook/pack.htm
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.