Skip to content

Unable to use scrollbar when attaching to option menu if using CTkScrollableDropdownFrame [FIX (maybe)] #50

@hardlyprogramming

Description

@hardlyprogramming

I was unable to use the scrollbar (or even bind mousewheel) to the dropdown menu as any type of button event caused the menu to withdraw. It should be noted that I only experienced this issue when using CTkScrollableDropdownFrame.

I found a fix. Though I'm not sure if it could potentially affect something else. In any case this is what worked for me:

FIX:

comment out line 27 in ctk_scrollable_dropdown_frame.py:

# self.attach.winfo_toplevel().bind("<ButtonPress>", lambda e: self._withdraw() if not self.disable else None, add="+") 

If interested, I was having a hard time binding the mouse-wheel to the dropdown menu. Adding these lines to CTkScrollableDropdownFrame class after "self.frame" is created and configured is what finally worked. However, this could just be a knowledge gap on my part.

        self.frame._scrollbar.grid_configure(padx=3)

        ########################### MODIFIED CODE ######################
        #   This binds the mousewheel to be able to scroll in the optionmenu dropdown  #
        
        # if using linux
        self.frame.bind_all('<Button-4>', lambda e: self.frame._parent_canvas.yview_scroll(-1, 'units'))
        self.frame.bind_all('<Button-5>', lambda e: self.frame._parent_canvas.yview_scroll(1, 'units'))

        # If using windows
        #  self.frame.bind_all('<MouseWheel>'), lambda e: self.frame._parent_canvas.yview_scroll(1, 'units))

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions