I expect my code below to display the image from file 'apple.png' in the rootTwo Tkinter window. However when I press the button to open said window nothing shows. I can see the background is working in the secound window, just not the placement of the photo.
You can see in the photo's further down that the background works in the second window, and that the method of placing the image works in the first, so whats got to give...?
import tkinter as tk
from PIL import Image as img
from PIL import ImageTk as itk
def testWindowTwo ():
rootTwo = tk.Tk()
rootTwo.geometry('900x300')
rootTwo.resizable(False, False)
rootTwo.title('Testing2')
canvasTest = tk.Canvas(rootTwo, bg='red')
canvasTest.pack()
appleImgPre = img.open('apple.png')
appleImgPre = appleImgPre.resize((50,50))
appleImg = itk.PhotoImage(appleImgPre)
canvasTest.create_image(75,75, image=appleImg)
rootTwo.mainloop()
root = tk.Tk()
root.geometry('1280x720')
root.configure(bg='#398AD7')
root.title('Testing')
canvasMain = tk.Canvas(root, width=1920, height=1080, bg='red')
canvasMain.pack()
imgTestPre = img.open('apple.png')
imgTestPre = imgTestPre.resize((50,50))
imgTest = itk.PhotoImage(imgTestPre)
canvasMain.create_image(75, 75, image=imgTest)
myButton = tk.Button( width=10, height=5, text='test', command=testWindowTwo)
canvasMain.create_window(300, 300, window=myButton)
root.mainloop()
[
FIRST WINDOW ^^^^