0

All images are getting into garbage collection except the last one. How to show all images?

 t = 1 images = [] while t < total_t[0][0]: row = self.database.db_query(F"SELECT * FROM {self.database.main_table} where T_ID = {t}") t_type = row[0][1] t_kind = row[0][2] t_note = row[0][3] t_date = row[0][4] t_ammount = row[0][5] self.img = tk.PhotoImage(file=f"{transactions_path}{t-1}.png") images.append(self.img) t+=1 for index, image in enumerate(images): self.image = image tk.Label(self.content_view_frame, image=self.image).grid(row=index) 
3
  • 1
    You need to keep a reference to each image. You see the last one because a reference to that one is inside self.image. Change images to self.images and it should work. Commented Mar 22, 2021 at 10:10
  • @Pietro Thankyouu sooo much It worked. Commented Mar 22, 2021 at 10:27
  • @Pietro You can add that as an answer. Commented Mar 22, 2021 at 10:49

1 Answer 1

1

You need to keep a reference to each image. You see the last one because a reference to that one is inside self.image. Change images to self.images and it should work.

Cheers!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.