tkinter askstring deleted before its visibility changed tkinter askstring deleted before its visibility changed tkinter tkinter

tkinter askstring deleted before its visibility changed


I know this is an old thread, but I'm having the same problem and so far haven't found the root cause.

However, this workaround works for me in case anyone else needs it:

#Create a new temporary "parent"newWin = Tk()#But make it invisiblenewWin.withdraw()#Now this works without throwing an exception:retVal = simpledialog.askstring("Enter Value","Please enter a value",parent=newWin)#Destroy the temporary "parent"newWin.destroy()


I was also able to work around the problem by using the above workaround suggested by John D.

I did some research on this, and it seems that this exception is raised when all of the following conditions are met.

  • The thread that called the simpledialog.askstring method is not the main thread.
  • The Tk window specified in the parent or the Tk window specified in the default_root variable is different from the thread that called the simpledialog.askstring method.

However, I could not come up with a process to deal with this problem. I hope this helps to solve the problem.