As I said in a comment, you're putting the same image in every row and column of the grid. Here's how to avoid that using the built-in divmod()
function to iteratively compute the row and column for each one, based on the number of COLUMNS
you want to display in each row based on the current value of image_count
:
def messageWindow():
win = Toplevel()
path = r'C:\Users\HP\Desktop\dataset'
COLUMNS = 10
image_count = 0
for infile in glob.glob(os.path.join(path, '*.jpg')):
image_count += 1
r, c = divmod(image_count-1, COLUMNS)
im = Image.open(infile)
resized = im.resize((100, 100), Image.ANTIALIAS)
tkimage = ImageTk.PhotoImage(resized)
myvar = Label(win, image=tkimage)
myvar.image = tkimage
myvar.grid(row=r, column=c)
win.mainloop() # Not sure if you need this, too, or not...