mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed #925
This commit is contained in:
parent
5bbd72b5dc
commit
1396a7e484
@ -107,13 +107,31 @@ class CTkButton(CTkBaseClass):
|
||||
|
||||
def _create_bindings(self, sequence: Optional[str] = None):
|
||||
""" set necessary bindings for functionality of widget, will overwrite other bindings """
|
||||
|
||||
if sequence is None or sequence == "<Enter>":
|
||||
self._canvas.bind("<Enter>", self._on_enter)
|
||||
|
||||
if self._text_label is not None:
|
||||
self._text_label.bind("<Enter>", self._on_enter)
|
||||
if self._image_label is not None:
|
||||
self._image_label.bind("<Enter>", self._on_enter)
|
||||
|
||||
if sequence is None or sequence == "<Leave>":
|
||||
self._canvas.bind("<Leave>", self._on_leave)
|
||||
|
||||
if self._text_label is not None:
|
||||
self._text_label.bind("<Leave>", self._on_leave)
|
||||
if self._image_label is not None:
|
||||
self._image_label.bind("<Leave>", self._on_leave)
|
||||
|
||||
if sequence is None or sequence == "<Button-1>":
|
||||
self._canvas.bind("<Button-1>", self._clicked)
|
||||
|
||||
if self._text_label is not None:
|
||||
self._text_label.bind("<Button-1>", self._clicked)
|
||||
if self._image_label is not None:
|
||||
self._image_label.bind("<Button-1>", self._clicked)
|
||||
|
||||
def _set_scaling(self, *args, **kwargs):
|
||||
super()._set_scaling(*args, **kwargs)
|
||||
|
||||
@ -541,7 +559,11 @@ class CTkButton(CTkBaseClass):
|
||||
if not (add == "+" or add is True):
|
||||
raise ValueError("'add' argument can only be '+' or True to preserve internal callbacks")
|
||||
self._canvas.bind(sequence, command, add=True)
|
||||
self._text_label.bind(sequence, command, add=True)
|
||||
|
||||
if self._text_label is not None:
|
||||
self._text_label.bind(sequence, command, add=True)
|
||||
if self._image_label is not None:
|
||||
self._image_label.bind(sequence, command, add=True)
|
||||
|
||||
def unbind(self, sequence: str = None, funcid: str = None):
|
||||
""" called on the tkinter.Label and tkinter.Canvas """
|
||||
@ -549,7 +571,12 @@ class CTkButton(CTkBaseClass):
|
||||
raise ValueError("'funcid' argument can only be None, because there is a bug in" +
|
||||
" tkinter and its not clear whether the internal callbacks will be unbinded or not")
|
||||
self._canvas.unbind(sequence, None)
|
||||
self._text_label.unbind(sequence, None)
|
||||
|
||||
if self._text_label is not None:
|
||||
self._text_label.unbind(sequence, None)
|
||||
if self._image_label is not None:
|
||||
self._image_label.unbind(sequence, None)
|
||||
|
||||
self._create_bindings(sequence=sequence) # restore internal callbacks for sequence
|
||||
|
||||
def focus(self):
|
||||
|
Loading…
Reference in New Issue
Block a user