Im creating an app where there is a window that opens another window. While this happens i want to set the state of the buttons that initialize this procedure as DISABLED but i keep getting this error.
def main():
def modify():
mods.config(state=DISABLED)
dell.config(state=DISABLED)
close.config(state=DISABLED)
while True:
errorbox.destroy()
win = Replacy(self,dbn,self.coln,self.it,client,tree,item)
win.resizable(False,False)
win.grab_set()
break
mods.config(state=NORMAL)
dell.config(state=NORMAL)
close.config(state=NORMAL)
def delete():
mods.config(state=DISABLED)
dell.config(state=DISABLED)
close.config(state=DISABLED)
def deldel():
tree.delete(item)
eeeeerrorbox.destroy()
coln.delete_one(self.it)
errorbox.destroy()
eeeeerrorbox = Tk()
eeeeerrorbox.geometry("255x80")
eeeeerrorbox.title("Error")
eeeeerrorbox.iconbitmap(False,fold +"/info.ico")
l2=Label(eeeeerrorbox,text='Are you sure you want to delete this entry?')
l2.grid(row=0, column=0, columnspan=3, pady=(7, 10),padx=10, sticky="w")
dellll = ttk.Button(eeeeerrorbox,text="Yes",command=deldel,width = 7)
dellll.grid(row=1, column=0,columnspan=2)
closeee = ttk.Button(eeeeerrorbox,text="No",command=eeeeerrorbox.destroy,width = 7)
closeee.grid(row=1, column=2)
eeeeerrorbox.resizable(False,False)
mods.config(state=NORMAL)
dell.config(state=NORMAL)
close.config(state=NORMAL)
eeeeerrorbox.mainloop()
errorbox = Tk()
errorbox.geometry("210x80")
errorbox.title("Error")
errorbox.iconbitmap(False,fold +"/info.ico")
l2=Label(errorbox,text='How would you like to edit this entry?')
l2.grid(row=0, column=0, columnspan=3, pady=(7, 10), sticky="w")
mods = ttk.Button(errorbox,text="Modify",command=modify,width = 7)
mods.grid(row=1, column=0)
dell = ttk.Button(errorbox,text="Delete",command=delete,width = 7)
dell.grid(row=1, column=1)
close = ttk.Button(errorbox,text="Close",command=errorbox.destroy,width = 7)
close.grid(row=1, column=2)
mods.config(state=NORMAL)
dell.config(state=NORMAL)
close.config(state=NORMAL)
errorbox.mainloop()
and this is the error i keep getting whatever i try or indenting or placing.
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\\Users\\nagia\\AppData\\Local\\Programs\\Python\\Python310\\lib\\tkinter\__init_\_.py", line 1921, in __call__
return self.func(\*args)
File "g:\\nagia\\Harris\\ProductivityReports 3.0\\history.py", line 65, in modify
mods.config(state=NORMAL)
File "C:\\Users\\nagia\\AppData\\Local\\Programs\\Python\\Python310\\lib\\tkinter\__init_\_.py", line 1675, in configure
return self._configure('configure', cnf, kw)
File "C:\\Users\\nagia\\AppData\\Local\\Programs\\Python\\Python310\\lib\\tkinter_init_.py", line 1665, in \_configure
self.tk.call(\_flatten((self.\_w, cmd)) + self.\_options(cnf))
\_tkinter.TclError: invalid command name ".!button"
however if i remove lines 65 66 67 then when the new window appears, the old one with the three buttons gets destroyed as if there is an invisible error but the app doesnt crash as it did before.
Any help is appreciated!!!!
The exception is because you have destroyed the window errorbox, so those widgets inside the windows are also destroyed. @acw1668
I just noticed that it gets destroyed in the while loop.
I just removed errorbox.destroy()
in the while loop and everything works like a charm