Кнопка Назад в Python, я хочу go вернуться в главное окно - PullRequest
0 голосов
/ 27 апреля 2020

У меня проблемы с кодом. Я хотел сделать кнопку возврата, и у меня появляется ошибка при отображении окна. Моя цель - сделать каталог, в котором пользователь может нажимать sh кнопок и взаимодействовать с продуктом. Но когда вы нажимаете кнопку sh, появляется эта ошибка.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/Users/williamgranizo/.conda/envs/untitled/lib/python3.7/tkinter/__init__.py", line 1705, in __call__
    return self.func(*args)
  File "/Users/williamgranizo/.conda/envs/untitled/lib/python3.7/site-packages/tkmacosx/basewidget.py", line 255, in cmd
    self.unbind_class('button_command', '<ButtonRelease-1>')
  File "/Users/williamgranizo/.conda/envs/untitled/lib/python3.7/site-packages/tkmacosx/basewidget.py", line 496, in unbind_class
    bindtags = list(self.bindtags())
  File "/Users/williamgranizo/.conda/envs/untitled/lib/python3.7/tkinter/__init__.py", line 1192, in bindtags
    self.tk.call('bindtags', self._w))
_tkinter.TclError: bad window path name ".!toplevel2.!button6"

Я не знаю, в чем главная проблема, но главное окно, похоже, все еще работает. Мой код:

def m1():

ventana.withdraw
modelo_1 = Toplevel()
modelo_1.title("Rose&Frites Hoodie con Gorra")
modelo_1.geometry("700x700")
modelo_1.configure(bg='black')
fn_1 = PhotoImage(file='mblac.png')
lblfn = Label(modelo_1, image=fn_1).place(x=0, y=0)
foto_1 = PhotoImage(file='mg_1.png')
nom_1 = Label(modelo_1, text ='Rose&Frites Hoodie con Gorra', fg ='black',
              font=('Arial',20,'bold')).place(x=375,y=50)
myfoto_1 = Label(modelo_1, image=foto_1).place(x=50, y=30)
text_1 = Label(modelo_1, text= 'Promoción!! Hoodie de color negro\n con una estampa en forma de rosa. '
                               '\nTejido principal: 65%'
                    ' algodón, 35% poliester.\nTejido secundario: 97% algodón, 3% elástico.'
                    '\n Gorra color amarillo con \n estampa de papas fritas.\n 97% algodón, 3% elástico'
                    '\n100% Hecho en Ecuador', bg='white', fg='black', font=('Arial', 16)).place(x=375, y=100)
tallas=Label(modelo_1,text="Tallas!",font=("Arial",16,'bold'),bg='white',fg='black').place(x=500,y=300)
xl = Button(modelo_1, text="XL",font=("Arial",9,"bold"),width=60,bg='black',fg='white').place(x=385,y=350)
l = Button(modelo_1, text="L",font=("Arial",9,"bold"),width=60,bg='black',fg='white').place(x=445,y=350)
m = Button(modelo_1, text="M",font=("Arial",9,"bold"),width=60,bg='black',fg='white').place(x=505,y=350)
s = Button(modelo_1, text='S',font=("Arial",9,'bold'),width=60,bg='black',fg='white').place(x=565,y=350)
xs = Button(modelo_1, text='XS',font=("Arial",9,'bold'),width=60,bg="black",fg="white").place(x=625,y=350)
precio = Label(modelo_1, text="$35.00", font=('Arial',15, 'bold')).place(x=50, y= 485)
cuidados=PhotoImage(file='cuidados.png')
cuidados1=Label(modelo_1,image=cuidados).place(x=375,y=400)
cuidados2=Label(modelo_1,text="Cuidados",font=("Arial",15,'bold')).place(x=500,y=505)
iva = Label(modelo_1,text='El precio no contiene I.V.A.', font=('Arial',14,'bold')).place(x=500,y=660)
back = Button(modelo_1, text='BACK!', font=('verdana', 14, 'bold'), fg='red',
              command= modelo_1.destroy).place(x=0, y=0)
...