E
E
ebarashec2020-12-25 18:25:58
Python
ebarashec, 2020-12-25 18:25:58

My program gives an error, how can I fix it?

from tkinter import *
from random import *

class Main:
    def __init__(self):
        global main_i
        Main.frame=Tk()
        main_i=True
        Main.frame.geometry("600x600")
        Main.img=PhotoImage(file="start.png")
        Main.frame.title("mini-games by SAVT")
        Main.frame["bg"]="black"
        Main.start=Button(Main.frame,image=Main.img,command=Main.s)
        Main.start.grid(row=0,column=0)
        Main.exit_b=Button(Main.frame,text="Выход",command=Main.ex)
        Main.exit_b.grid(row=1,column=0)

    def ex():
        Main.frame.destroy()

    def s():
        a=Choice()


class Choice:
    def __init__(self):
        global main_i
        self.frame=Tk()
        self.img=PhotoImage(file="ssp.png")
        if main_i==True:
            Main.frame.destroy()
        self.frame.geometry("600x600")
        self.frame.title("mini-games by SAVT")
        self.frame["bg"]="black"
        self.s_s_p_b=Button(self.frame,image=self.img)
        self.s_s_p_b.grid(row=0,column=0)

class S_s_p:
    pass

main_i=False
main=Main()
mainloop()
Error:
C:\Users\stptk\AppData\Local\Programs\Python\Python38-32\python.exe "C:/mini-games/mini-games by SAVT.py"
Exception in Tkinter callback
Traceback (most recent call last ):
File "C:\Users\stptk\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:/ mini-games/mini-games by SAVT.py", line 22, in s
a=Choice()
File "C:/mini-games/mini-games by SAVT.py", line 35, in __init__
self.s_s_p_b= Button(self.frame,image=self.img)
File "C:\Users\stptk\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2645, in __init__
Widget.__init__ (self, master, 'button',cnf, kw)
File "C:\Users\stptk\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 2567, in __init__
self.tk.call(
_tkinter.TclError: image "pyimage2" doesn't 't exist

Note:
Tabs and names with file format preserved.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Karbivnichy, 2020-12-25
@hottabxp

'image “pyimage2” doesn't exist'?
Google is full of links to this error.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question