0
import tkinter as tk                # python 3
from tkinter import StringVar, font  as tkfont # python 3
from tkinter import messagebox
from PIL import ImageTk, Image

#################################################################second window
window=tk.Tk()

window.title("title")
window.geometry("1500x800")
RadioVariety_2=tk.IntVar()        

radio1=tk.Radiobutton(window, text="1번", value=1, variable=RadioVariety_2)
radio1.place(x=40,y=550)

def new_page():
    window = tk.Toplevel()
    window.grab_set()


#########################################################################frist window
mainWindow = tk.Tk()

TitlePhoto = tk.PhotoImage(file="TitlePhoto.png")
 
Title = tk.Label(mainWindow, image = TitlePhoto)
Title.image = TitlePhoto
Title.place(x=230,y=50)

mainWindow.mainloop()

error message

  File "c:\Users\y\Desktop\project\stackoverflow.py", line 36, in <module>   
    Title = tk.Label(mainWindow, image = TitlePhoto)   
  File "C:\Users\y\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2766, in __init__   
    Widget.__init__(self, master, 'label', cnf, kw)   
  File "C:\Users\y\AppData\Local\Programs\Python\Python37\lib\tkinter\__init__.py", line 2299, in __init__   
    (widgetName, self._w) + extra + self._options(cnf))   
_tkinter.TclError: image "pyimage1" doesn't exist   

I want to make a new window in a tkinter.
I have a file in the same folder, but error occurs.
What should I do?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • 1
    It is because there are two instances of `Tk()`. Why do you create two instances of `Tk()`? – acw1668 Jun 01 '22 at 00:43
  • If you search for the exact error message you'll probably find an answer. – Bryan Oakley Jun 01 '22 at 00:51
  • Does https://stackoverflow.com/questions/23224574/tkinter-create-image-function-error-pyimage1-does-not-exist answer your question? – Karl Knechtel Jun 01 '22 at 00:54
  • @BryanOakley when I try that, I find a lot of 0-vote questions and the occasional result like what I'm suggesting here. It's not clear what is or isn't related to the actual problem. – Karl Knechtel Jun 01 '22 at 00:54

0 Answers0