title: Displaying pics in Labels with a for Statement using tkinter, can it be done?
body: <p>I am trying to get a random bunch of pictures to print side by side; the problem is that if I run the following code all that happens is that it creates a group of blank empty labels. If I replace the 'image=pic' with a "text='whatever'" it works fine (thus proving that it dows actually create the label). Placing the label and image anywhere else works fine (proving that it's not the images), even if I use 'pic = PhotoImage(file=w[0])' it works (so I don't think its my method)... </p>
  
  <pre><code>from tkinter import *
  from tkinter import ttk
  import random
  
  root = Tk()
  root.title("RandomizedPic")
  
  def randp(*args):
      w = ['wb.gif', 'wc.gif', 'wd.gif', 'we.gif']
      random.shuffle(w)
      am = 1
  
      for i in w:
          pic = PhotoImage(file=i)
          ttk.Label(mainframe, image=pic).grid(column=am, row=0, sticky=(W, E))
          am+=1
  
  
  mainframe = ttk.Frame(root, padding="3 3 12 12")
  mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
  mainframe.columnconfigure(0, weight=1)
  mainframe.rowconfigure(0, weight=1)
  
  ttk.Button(mainframe, text="Do it", command=randp).grid(column=0, row=0, sticky=W)
  
  root.bind('&lt;Return&gt;', randp)
  root.mainloop()
  </code></pre>
  
  <p>Any advice on how to get this to work will be much appreciated.</p>