israel-dryer/ttkbootstrap

Destroying a scrolledframe while it is under the cursor gives bad window path

sambler opened this issue · 0 comments

Desktop (please complete the following information):

ttkbootstrap v1.10.1

Describe the bug

Destroying a scrolledframe when the cursor is over it causes a bad window path error. No error if the cursor is outside of the scrolledframe.

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/tkinter/__init__.py", line 1892, in __call__
    return self.func(*args)
  File "/home/shane/.local/lib/python3.9/site-packages/ttkbootstrap/scrolled.py", line 455, in _on_leave
    self.disable_scrolling()
  File "/home/shane/.local/lib/python3.9/site-packages/ttkbootstrap/scrolled.py", line 414, in disable_scrolling
    self._del_scroll_binding(self)
  File "/home/shane/.local/lib/python3.9/site-packages/ttkbootstrap/scrolled.py", line 394, in _del_scroll_binding
    children = parent.winfo_children()
  File "/usr/local/lib/python3.9/tkinter/__init__.py", line 1050, in winfo_children
    self.tk.call('winfo', 'children', self._w)):
_tkinter.TclError: bad window path name ".!frame3.!scrolledframe"

To Reproduce

Place the cursor over a scrolledframe when you destroy it.

A minimal example to run - press F5 to destroy and re-create the frame:

import tkinter as tk
from ttkbootstrap.scrolled import ScrolledFrame

class Main(tk.Tk):
    def __init__(self):
        super().__init__()
        self.list_items()
        self.bind('<F5>', self.list_items)

    def list_items(self, evnt=None):
        if hasattr(self, 'sf'):
            self.sf.destroy()
        self.sf = ScrolledFrame(self)
        self.sf.grid(row=1, column=0, sticky=tk.NSEW)

if __name__ == '__main__':
    mw = Main()
    mw.mainloop()

Expected behavior

No exception output when destroying the scrolledframe.

Screenshots

No response

Additional context

No response