As most of us know in tkinter in order to properly display an image it must be assigned to a variable, however what if you don't know that amount of images that are going to be necessary? i.e. A friend list, how would one display the friends pictures?

Recommended Answers

Does the friend list bring anything to mind?

Jump to Post

All 4 Replies

Does the friend list bring anything to mind?

It does, but I'm stuck in a pattern of thinking I can't get out of with the use of it, here's what I've been trying:
        for img in list1:

This just puts the word (pyimage"whatever number") in the box, which makes sense "unfortunately" any alternative ideas?

And to make sure that it wasn't just the listbox being an issue

def create_widget(self):
        for file in list1:

I do not know details by heart, but for this part I would think that code would go more like:
        list1=[PhotoImage(file=img) for img in 'icon_man.gif','group_icon.gif']
        for imag in list1:

Maybe even with generator expression:
        for imag in (PhotoImage(file=img) for img in 'icon_man.gif','group_icon.gif'):

It seems the best way, at least to me, is to have a set amount labels with images on the page, and have something like a next button that will reassign the image value of the label.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.