Scrolling in a dialog from tkinter.filedialog is causing exceptions in CTkScrollableFrame

Author: KniylCreated Sep 4, 2026Updated Sep 8, 2026

For some reasons, scroll events generated by dialogs from tkinter.filedialog (for instance using tkinter.filedialog.askdirectory) use a string representation as their widget attribute. However, if the main window uses CTkScrollableFrames, they end up catching the event and trying to act upon it leading to the following exception flooding the console:

Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.12/tkinter/__init__.py", line 1967, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "<virtualenv>/lib/python3.12/site-packages/customtkinter/windows/widgets/ctk_scrollable_frame.py", line 265, in _mouse_wheel_all
    if self._check_if_valid_scroll(event.widget):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<virtualenv>/lib/python3.12/site-packages/customtkinter/windows/widgets/ctk_scrollable_frame.py", line 302, in _check_if_valid_scroll
    elif widget.master is not None:
         ^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'master'

Although harmless since the event should not be acted upon by any scrollable frame, it would be nice to get rid of it as it might be disturbing for some users.

Simplified code to reproduce the behavior:

python
import customtkinter as tk


class Root(tk.CTk):
    def __init__(self):
        super().__init__()
        self.title('Demo')
        tk.CTkButton(self, text='Open File Dialog', command=self.open).pack(side='top', fill='x')
        tk.CTkScrollableFrame(self, label_text='uh oh!').pack(side='top', fill='both', expand=True)

    def open(self):
        directory = tk.filedialog.askdirectory(master=self, title='Scroll to generate exception')
        print('Selected directory:', directory)


Root().mainloop()

Source: TomSchimansky/CustomTkinter