CustomTkinter icon indicating copy to clipboard operation
CustomTkinter copied to clipboard

Scrolling on ttk.Combobox with CTkScrollableFrame underneath

Open t-poplawski opened this issue 1 year ago • 1 comments

Scrolling on Combobox droplist from tkinter.ttk module raises exception when there's CTkScrollableFrame underneath.

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python311\Lib\tkinter\__init__.py", line 1948, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python311\Lib\site-packages\customtkinter\windows\widgets\ctk_scrollable_frame.py", line 248, in _mouse_wheel_all
    if self.check_if_master_is_canvas(event.widget):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[user]\AppData\Local\Programs\Python\Python311\Lib\site-packages\customtkinter\windows\widgets\ctk_scrollable_frame.py", line 280, in check_if_master_is_canvas
    elif widget.master is not None:
         ^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'master

Sample code:

import tkinter as tk
import tkinter.ttk as ttk
import customtkinter as ctk

def display_combobox(root):
    sample_values = ['test' for _ in range(30)]
    combo_box = ttk.Combobox(root, values=sample_values)
    combo_box.place(anchor='center', relx=0.5, rely=0.3)

def display_scrollable(root):
    scrollabe_frame = ctk.CTkScrollableFrame(root, label_text='text', width=150)
    scrollabe_frame.place(anchor='center', relx=0.5, rely=0.6)

if __name__ == '__main__':
    root = tk.Tk()
    root.geometry('500x500')
    display_combobox(root)
    display_scrollable(root)

    root.mainloop()

image

t-poplawski avatar Jun 04 '24 15:06 t-poplawski

Either make a sample reproducible code available or checkout the following for instant solution: https://github.com/Akascape/CTkScrollableDropdown

Regards.

dipeshSam avatar Jun 05 '24 03:06 dipeshSam