title: Python picture grid in loop
body: <p>I encountered a problem as I tried to fill a tkinter grid with a loop</p>
  
  <pre><code>i=0
  for category in categories:
      self.image = PhotoImage(file=category[2]+".png")
      imageLabel = Label(master, image=self.image)
      imageLabel.grid(row=0, column=i)
      i = i + 1
  </code></pre>
  
  <p>With this code I try to create a row with different pictures side by side.
  But it shows only the last image which is in the categories array (this array was filled by a SQL-execute btw).</p>
  
  <p>After a few researches I found out, that it seems that python overwrites the reference of the picture on each iteration.</p>
  
  <p>So I tried to change the code and save the references in a array:</p>
  
  <pre><code>folderPictures = []
  i = 0
  for category in categories:
      self.image = PhotoImage(file=category[2]+".png")
      imageLabel = Label(master, image=self.image)
      folderPictures.append(imageLabel)
  
  for pictures in folderPictures:
          pictures.grid(row=0, column=i)
          i = +1
  </code></pre>
  
  <p>unfortunately this doesn't work either. What do I do wrong?</p>
  
  <p>Thanks and best regards
  Franz</p>