#Import python tkinter and Image library
from tkinter import *
from PIL import ImageTk, Image
#making function
def func():
top = Tk()
image = ImageTk.PhotoImage(file = 'my_image.png')
b1 = Button(top, image=image).grid(row=0, column=0)
top.mainloop()
#main
win = Tk()
#I want this button to open another window where it shows a button with an Image on it.
b2 = Button(top, text='Click to open new window', command=func).grid(row=0, column=0)
win.mainloop()
#Output
#pyimage1 doesn't exist.
It should have shown a window with a button that takes me to another window where there is an image button. This should have worked but in mine, it shows the above output.