added .invoke() method to button #605

This commit is contained in:
Tom Schimansky
2022-11-11 00:32:52 +01:00
parent 2c31f18dc1
commit f18ac0c81a
2 changed files with 15 additions and 8 deletions

View File

@ -513,16 +513,22 @@ class CTkButton(CTkBaseClass):
self._on_enter()
def _clicked(self, event=None):
if self._command is not None:
if self._state != tkinter.DISABLED:
if self._state != tkinter.DISABLED:
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
self._on_leave()
self._click_animation_running = True
self.after(100, self._click_animation)
# click animation: change color with .on_leave() and back to normal after 100ms with click_animation()
self._on_leave()
self._click_animation_running = True
self.after(100, self._click_animation)
if self._command is not None:
self._command()
def invoke(self):
""" calls command function if button is not disabled """
if self._state != tkinter.DISABLED:
if self._command is not None:
return self._command()
def bind(self, sequence: str = None, command: Callable = None, add: str = None) -> str:
""" called on the tkinter.Label and tkinter.Canvas """
canvas_bind_return = self._canvas.bind(sequence, command, add)