I am trying to add a bunch of images from a folder using a for loop using tkinter and I want each image to be placed on row = 20, but change columns for each image. So , I will want an image on (20,10), (20,11), (20,12) and so on. This works when I use grid for individual images, but I cant get it to work in a for loop where I want to add 5 images. Instead my first image starts appearing in the first row and first column but follows the column increments. Please let me know what I am doing wrong here? Thanks!
game = tkinter.Tk()
game.geometry("500x500")
images = random.sample(deck, 5)
path = "C:/Users/jhbhb/Documents/"
MAX_ROWS = 4
current_row = 20
current_column = 10
for file in images:
im = Image.open(f"{path}/{file}.png")
photo = ImageTk.PhotoImage(im)
label = tkinter.Label(image=photo)
label.image = photo
label.grid(row=current_row, column=current_column)
current_column += 1
game.mainloop()