Ребят проблема в коде
Есть код программы в нем куча кнопок, но в меню ussb есть 5 кнопок, они работают хорошо, но если допустим нажать на кнопку открытия меню2 в этом меню есть кнопка закрытия после нажатия на это кнопку открывается старое меню1, но кнопка входа в меню2 перестанет работать без ошибок в консоли. (Код написан плохо для редактирования оставлю полностью вдруг кто то разберется) Так же там почти везде есть global withdraw() или destroy() разнице нет
def sozt():
sozd = Toplevel(tk)
sozd.geometry("400x400")
sozd.title("О создателе")
sozd.resizable(width=False, height=False)
sozd.image = PhotoImage(file="image/russianEmage/o_avtore.png")
oprog = Toplevel(tk)
oprog.geometry("800x400")
oprog.title("О программе")
oprog.resizable(width=False, height=False)
oprog.image = PhotoImage(file="image/russianEmage/О_программе.png")
screen4 = Label(oprog, image=oprog.image)
screen4.grid(row=0, column=0)
def ext1():
tk.destroy()
def ussb():
global ussb
ussb = Toplevel(tk)
ussb.geometry("1280x900")
ussb.title("USB version")
ussb.resizable(width=False, height=False)
ussb.image = PhotoImage(file="image/russianEmage/ussbpin.png")
screen8 = Label(ussb, image=ussb.image)
screen8.grid(row=0, column=0)
bl = Button(ussb,image = winak, command = aktiv)
bl.place(x=100,y=400, width=300, height=100)
bl = Button(ussb,image = oboi, command = oboi1)
bl.place(x=100,y=550, width=300, height=100)
bl = Button(ussb,image = prog, command = installers)
bl.place(x=450,y=400, width=300, height=100)
bl = Button(ussb,image = razOC, command = razgen)
bl.place(x=450,y=550, width=300, height=100)
bl = Button(ussb, image = nazadd2, command = nazaddd)
bl.place(x=5,y=845, width=200, height=50)
bl = Button(ussb, image = voskl, command = voskl2)
bl.place(x=210,y=845, width=50, height=50)
tk.withdraw()
def voskl2():
voskl2 = Toplevel(tk)
voskl2.geometry("300x300")
voskl2.title("Осторожно")
voskl2.resizable(width=False, height=False)
#screen19 = Label(voskl2, image=razgon)
#screen19.grid(row=0, column=0)
def razgen():
global razgen
razgen = Toplevel(tk)
razgen.geometry("500x400")
razgen.title("Выбор платформы")
razgen.resizable(width=False, height=False)
screen18 = Label(razgen, image=razgon)
screen18.grid(row=0, column=0)
bl = Button(razgen, image = razgIntel, command = razIntel)
bl.place(x=40,y=120, width=200, height=100)
bl = Button(razgen, image = razgAMD, command = razAMD)
bl.place(x=250,y=120, width=200, height=100)
def razIntel():
global razIntel
razIntel = Toplevel(tk)
razIntel.geometry("1280x720")
razIntel.title("Intel core ")
razIntel.resizable(width=False, height=False)
bl = Button(razIntel, image = nazadd2, command = intelexit)
bl.place(x=5,y=660, width=200, height=50)
razgen.withdraw()
ussb.withdraw()
def razAMD():
global razAMD
razAMD = Toplevel(tk)
razAMD.geometry("1280x720")
razAMD.title("AMD")
razAMD.resizable(width=False, height=False)
bl = Button(razAMD, image = nazadd2, command = amdexit)
bl.place(x=5,y=660, width=200, height=50)
razgen.withdraw()
ussb.withdraw()
def amdexit():
ussb.deiconify()
razAMD.withdraw()
def intelexit():
ussb.deiconify()
razIntel.withdraw()
def installers():
global installers
installers = Toplevel(tk)
installers.geometry("1280x720")
installers.title("Выбор программ")
installers.resizable(width=False, height=False)
screen19 = Label(installers, image=installerss)
screen19.grid(row=0, column=0)
ussb.withdraw()
bl = Button(installers, image = nazadd2, command = eeitttl)
bl.place(x=5,y=660, width=200, height=50)
def eeitttl():
ussb.deiconify()
installers.withdraw()
def nazaddd():
ussb.withdraw()
tk.deiconify()
def oboi1():
oboi = Toplevel(tk)
oboi.geometry("500x200")
oboi.title("Выбор обоев")
oboi.resizable(width=False, height=False)
screen12 = Label(oboi, image=sprosobi)
screen12.grid(row=0, column=0)
bl = Button(oboi,image = animoct, command = lambda obj=oboi: animeoct(oboi))
bl.place(x=255,y=100, width=150, height=75)
bl = Button(oboi, image = animoobrat, command = lambda obj=oboi: nanimeno(oboi))
bl.place(x=70,y=100, width=150, height=75)
def nanimeno(obj):
global nanimeno
nanimeno = Toplevel(tk)
nanimeno.geometry("1280x600")
nanimeno.title("Обои")
nanimeno.resizable(width=False, height=False)
screen13 = Label(nanimeno, image=viberit)
screen13.grid(row=0, column=0)
bl = Button(nanimeno, image = dalee, command = dale)
bl.place(x=700,y=530, width=150, height=75)
bl = Button(nanimeno, image = vahod, command = exitt3)
bl.place(x=550,y=530, width=150, height=75)
ussb.withdraw()
obj.withdraw()
def dale():
global dale
dale = Toplevel(tk)
dale.geometry("1280x600")
dale.title("Обои")
dale.resizable(width=False, height=False)
screen15 = Label(dale, image=viberit)
screen15.grid(row=0, column=0)
bl = Button(dale, image = nazad, command = exitt333)
bl.place(x=550,y=530, width=150, height=75)
nanimeno.withdraw()
def exitt333():
dale.withdraw()
nanimeno.deiconify()
def exitt3():
ussb.deiconify()
nanimeno.withdraw()
def animeoct(obj):
global oboiaime
oboiaime = Toplevel(tk)
oboiaime.geometry("1280x600")
oboiaime.title("Обои")
oboiaime.resizable(width=False, height=False)
screen13 = Label(oboiaime, image=viberit)
screen13.grid(row=0, column=0)
bl = Button(oboiaime, image = dalee, command = dal)
bl.place(x=700,y=530, width=150, height=75)
bl = Button(oboiaime, image = vahod, command = exitt)
bl.place(x=550,y=530, width=150, height=75)
bl = Button(oboiaime, image = liza, command = lizaa)
bl.place(x=257,y=150, width=256, height=144)
bl = Button(oboiaime, image = anime2, command = anim2)
bl.place(x=513,y=150, width=256, height=144)
bl = Button(oboiaime, image = anime3, command = anim3)
bl.place(x=769,y=150, width=256, height=144)
bl = Button(oboiaime, image = anime4, command = anim4)
bl.place(x=1,y=150, width=256, height=144)
bl = Button(oboiaime, image = winpirat, command = winrt)
bl.place(x=1025,y=150, width=256, height=144)
bl = Button(oboiaime, image = anime5, command = anime55)
bl.place(x=257,y=296, width=256, height=144)
bl = Button(oboiaime, image = intell, command = intel)
bl.place(x=513,y=296, width=256, height=144)
bl = Button(oboiaime, image = anime6, command = anim6)
bl.place(x=769,y=296, width=256, height=144)
bl = Button(oboiaime, image = anime7, command = anim7)
bl.place(x=1,y=296, width=256, height=144)
bl = Button(oboiaime, image = huangg, command = huang)
bl.place(x=1025,y=296, width=256, height=144)
obj.withdraw()
ussb.withdraw()
def exitt():
ussb.deiconify()
oboiaime.withdraw()
def dal():
global dal
dal = Toplevel(tk)
dal.geometry("1280x600")
dal.title("Выбор обоев")
dal.resizable(width=False, height=False)
screen13 = Label(dal, image = vibordal)
screen13.grid(row=0, column=0)
bl = Button(dal, image = nazad, command = backk2)
bl.place(x=400,y=530, width=150, height=75)
bl = Button(dal, image = vahod, command = exitt2)
bl.place(x=550,y=530, width=150, height=75)
bl = Button(dal, image = dalee, command = epoct)
bl.place(x=700,y=530, width=150, height=75)
oboiaime.withdraw()
def exitt2():
ussb.deiconify()
dal.withdraw()
def backk2():
dal.withdraw()
oboiaime.deiconify()
def epoct():
global epoct
epoct = Toplevel(tk)
epoct.geometry("1280x600")
epoct.title("Выбор обоев")
epoct.resizable(width=False, height=False)
screen14 = Label(epoct, image = vibordal)
screen14.grid(row=0, column=0)
bl = Button(epoct, image = vahod, command = exxxxxit)
bl.place(x=550,y=530, width=150, height=75)
bl = Button(epoct, image = nazad, command = backk3)
bl.place(x=400,y=530, width=150, height=75)
dal.withdraw()
def exxxxxit():
ussb.deiconify()
epoct.withdraw()
def backk3():
epoct.withdraw()
dal.deiconify()
import ctypes
from pathlib import Path
def lizaa():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/amd.jpg').as_posix(), 0)
def winrt():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/win.jpg').as_posix(), 0)
def anim2():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime2.jpg').as_posix(), 0)
def anim3():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime3.jpg').as_posix(), 0)
def anim4():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime4.png').as_posix(), 0)
def anime55():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime5.jpg').as_posix(), 0)
def intel():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/intel.png').as_posix(), 0)
def anim6():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime6.jpg').as_posix(), 0)
def anim7():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/anime7.png').as_posix(), 0)
def huang():
img_dir = Path(__file__).parent
ctypes.windll.user32.SystemParametersInfoW(20, 0, img_dir.joinpath('font/huang.png').as_posix(), 0)
def aktiv():
global aktivwin
aktivwin = Toplevel(tk) #Открытое англиского меню
aktivwin.geometry("400x200") #Геометрия окна
aktivwin.title("активация windows") #Названия окна
aktivwin.resizable(width=False, height=False) #Запрет на изменение окна (англ. версия)
aktivwin.image = PhotoImage(file="image/russianEmage/otklanivirus.png") #Экран англиский
screen11 = Label(aktivwin, image=aktivwin.image) #Экран выбора режима и языка(англиский)
screen11.grid(row=0, column=0) #Экран выбора режима и языка(англиский)
bl = Button(aktivwin,image = aktivwinbut, command = aktivbut) #Кнопка USB +En
bl.place(x=75,y=120, width=250, height=60) #Размеры кнопки USB
def aktivbut():
import os
os.startfile("DLL_files\\usb\\kms\\kms.exe")
aktivwin.withdraw()
def onlin(): #Кнопка смены языка
global onlin
online= Toplevel(tk) #Открытое англиского меню
online.geometry("1290x900") #Геометрия окна
online.title("online installer") #Названия окна
online.resizable(width=False, height=False) #Запрет на изменение окна (англ. версия)
online.image = PhotoImage(file="image/russianEmage/onlinepin.png") #Экран англиский
screen9 = Label(online, image=online.image) #Экран выбора режима и языка(англиский)
screen9.grid(row=0, column=0) #Экран выбора режима и языка(англиский)
tk.withdraw()
from tkinter import * #Импорт графического окна TkInter
import webbrowser #Импортирован браузер для онлаин версии
import ctypes
tk = Tk()
tk.title("D0LSTEK INSTALLER HELPER")
tk.geometry("1280x900")
tk.image = PhotoImage(file="image/russianEmage/режим _установки1.png")
screen1 = Label(tk, image=tk.image)
screen1.grid(row=0, column=0)
tk.resizable(width=False, height=False)
sozd = PhotoImage(file="image/russianEmage/sozd.png")
bl = Button(tk,image = sozd, command = sozt)
bl.place(x=210,y=848, width=200, height=50)
OPROG = PhotoImage(file="image/russianEmage/o_programe.png")
bl = Button(tk,image = OPROG, command = oprog)
bl.place(x=210,y=798, width=200, height=50)
svapLANG = PhotoImage(file="image/russianEmage/key_english.png")
bl = Button(tk,image = svapLANG, command = change_language)
bl.place(x=410,y=798, width=200, height=100)
online = PhotoImage(file="image/russianEmage/online.png")
bl = Button(tk,image = online, command = onlin)
bl.place(x=450,y=500, width=200, height=100)
usb = PhotoImage(file="image/russianEmage/usb.png")
bl = Button(tk,image = usb, command = ussb)
bl.place(x=650,y=500, width=200, height=100)
exit1 = PhotoImage(file="image/russianEmage/exit.png")
bl = Button(tk,image = exit1, command = ext1)
bl.place(x=12,y=798, width=200, height=100)
git = PhotoImage(file="image/russianEmage/git.png")
bl = Button(tk, image=git, command=lambda: webbrowser.open("https://github.com/d0lstek", new=2, autoraise="True"))
bl.place(x=610,y=798, width=200, height=100)
Button.pack
ruEn = PhotoImage(file="image/EnglishImage/RUEn.png")
exit1En = PhotoImage(file="image/EnglishImage/exitEn.png")
sozdEn = PhotoImage(file="image/EnglishImage/sozdEn.png")
OPROGEn = PhotoImage(file="image/EnglishImage/o_programeEm.png")
git1 = PhotoImage(file="image/russianEmage/git.png")
oprog.image = PhotoImage(file="image/EnglishImage/О_программеEn.png")
winak = PhotoImage(file="image/russianEmage/aktivwin.png")
cretEn1 = PhotoImage(file="image/russianEmage/avtoreEn.png")
aktivwinbut = PhotoImage(file="image/russianEmage/aktivbutton.png")
activEn = PhotoImage(file="image/EnglishImage/aktbut.png")
oboi = PhotoImage(file="image/russianEmage/oboi.png")
prog = PhotoImage(file="image/russianEmage/prog.png")
razOC = PhotoImage(file="image/russianEmage/razOC.png")
sprosobi = PhotoImage(file="image/russianEmage/oboivibor.png")
animoct = PhotoImage(file="image/russianEmage/animoct.png")
animoobrat = PhotoImage(file="image/russianEmage/ubrataime.png")
liza = PhotoImage(file="image/russianEmage/liza.png")
dalee = PhotoImage(file="image/russianEmage/dalee.png")
winpirat = PhotoImage(file="image/russianEmage/winpirat.png")
vahod = PhotoImage(file="image/russianEmage/vahod.png")
viberit = PhotoImage(file="image/russianEmage/vivirite.png")
anime2 = PhotoImage(file="image/russianEmage/anime2.png")
anime3 = PhotoImage(file="image/russianEmage/anime3.png")
anime4 = PhotoImage(file="image/russianEmage/anime4.png")
anime5 = PhotoImage(file="image/russianEmage/anime5.png")
anime6 = PhotoImage(file="image/russianEmage/anime6.png")
anime7 = PhotoImage(file="image/russianEmage/anime7.png")
intell = PhotoImage(file="image/russianEmage/intel.png")
huangg = PhotoImage(file="image/russianEmage/huang.png")
vibordal = PhotoImage(file="image/russianEmage/vivirite.png")
nazad = PhotoImage(file="image/russianEmage/nazad.png")
nazadd2 = PhotoImage(file="image/russianEmage/nazad2.png")
vk = PhotoImage(file="image/russianEmage/vk.png")
razgon = PhotoImage(file="image/russianEmage/razgon.png")
razgIntel = PhotoImage(file="image/russianEmage/razgIntel.png")
razgAMD = PhotoImage(file="image/russianEmage/razgAMD.png")
installerss = PhotoImage(file="image/russianEmage/installers.png")
voskl = PhotoImage(file="image/russianEmage/voskl.png")
tk.mainloop()