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()
Ошибка:
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 exist
Примечание:
Табуляции и имена с форматом файлов сохранён.