I am writing a longer program on a blackjack game, but there is one function that I am trying to make that I am having a hard time with. I am trying to write a function where when called, it will display an image. But when run, it will not display the image. But, if I run the same code outside of the function, it will display the image. Why will it not display the image when the function is called? Thank you,
George
import tkinter
def show_image(frame):
photo2 = tkinter.PhotoImage(file='cards/back.png')
tkinter.Label(mainWindow, image=photo2).pack(side='left')
mainWindow = tkinter.Tk()
mainWindow.geometry('640x480')
mainWindow.configure(bg='green')
photo = tkinter.PhotoImage(file='cards/back.png')
tkinter.Label(mainWindow, image=photo).pack(side='left')
show_image(mainWindow)
mainWindow.mainloop()