wait_window exception
Vasilis Vlachoudis <[email protected]> Wed, 18 Dec 2019 15:54:04 +0000
| Newsgroups | gmane.comp.python.tkinter |
|---|---|
| Message-ID | <[email protected]> |
What is the correct way to open a dialog and wait for the window
Typically I am doing the following
on a class subclassed of Toplevel
# ----------------------------------------------------------------------
def __init__(self, title=None,
master=None,
**kw):
super().__init__(master, class_="FileDialog")
self.transient(master)
self.title(title)
self.protocol("WM_DELETE_WINDOW", self.close)
# ... all initialization.... etc...
def show(self):
self.focus_set()
try:
self.deiconify()
self.wait_visibility()
self.update_idletasks()
self.grab_set()
except tk.TclError:
pass
self.wait_window()
Unfortunately, several times when the system is not very responsive I get a traceback
report from my users like
...
File \"/usr/local/flair/lib/bFileDialog.py\", line 361, in show
self.wait_window()
File \"/usr/lib64/python3.7/tkinter/__init__.py\", line 642, in wait_window
self.tk.call(\'tkwait\', \'window\', window._w)
_tkinter.TclError: bad window path name \".!flair.!configdialog3.!opendialog\"
Is there the possibility that the user clicks on the "Ok" or "Cancel" button before
the code execution arrives to the wait_window(), so when it is there it gives the error message.
Or can be something else that I am missing.
Thanks in advance
Vasilis