TomSchimansky / CustomTkinter

A modern and customizable python UI-library based on Tkinter
MIT License
11.58k stars 1.08k forks source link

bind_class not working as expected with <Button*> Events #2230

Open robinhoheisel opened 10 months ago

robinhoheisel commented 10 months ago

While working at a project I discovered that using bind_class with the

robinhoheisel commented 10 months ago

Hey,

This is suppsoed to be a minimal example to illustrate what I found. The actual project involves a listview with children composed from a larger number of sub widgets. Which has nothing to do with the issue at hand.

On my machine the click event for the customtkinter variant never triggers, while it does on the regular tkinter variant. That seems inconsistent, which is why I opened this issue.

MaxNiark commented 10 months ago

i found dat =>

accctualy using in my app, and the job is rly rly goood <3

Ctkmenubar.py, in CustomDropdownMenu.py Customtkinter Menu Bar Author: Akash Bora Custom Dropdown Menu for CTkMenuBar Original Author: LucianoSaldivia | https://github.com/LucianoSaldivia Modified by: Akascape

        if widget.master.winfo_name().startswith("!ctktitlemenu"):
            widget.master.master.bind("<Button-1>", self._checkIfMouseLeft, add="+")
            master = widget.master if master is None else master
            widget.master.menu.append(self)

        elif widget.master.winfo_name().startswith("!ctkmenubar"):
            widget.winfo_toplevel().bind("<Double-Button-1>", self._checkIfMouseLeft, add="+")
            master = widget.master.master if master is None else master
            widget.master.menu.append(self)
        else:
            widget.winfo_toplevel().bind("<Double-Button-1>", self._checkIfMouseLeft, add="+")
            master = widget.master if master is None else master

image

MaxNiark commented 10 months ago

ahah ok, there is a thing about trigger event

this both action don't make the same result, like your button

image