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

@ -10,7 +10,6 @@ ToDo:
- add new button attributes to wiki
- cursor configuring
- overwrite winfo methods
- renew input dialog
## Unreleased - 2022-10-2
### Added
@ -22,15 +21,17 @@ ToDo:
- Added 'anchor' option to CTkOptionMenu and 'justify' option to CTkComboBox
- Added CTkFont class
- Added CTkImage class to replace PIL.ImageTk.PhotoImage, supports scaling and two images for appearance mode, supports configuring
- Added missing configure options for multiple widgets
### Changed
- Changed value for transparent colors (same as background) from None to 'transparent'
- Changed 'text_font' attribute to 'font' in all widgets, changed 'dropdown_text_font' to 'dropdown_font'
- Changed 'dropdown_color' attribute to 'dropdown_fg_color' for combobox, optionmenu
- Changed 'orient' attribute of CTkProgressBar and CTkSlider to 'orientation'
- Width and height attributes of CTkCheckBox, CTkRadioButton, CTkSwitch now describe the outer dimensions of the whole widget. The button/switch size is described by separate attributes like checkbox_width, checkbox_height
- font attribute must be tuple or CTkFont now, all size values are measured in pixel now
- Changed dictionary key 'window_bg_color' to 'window' in theme files
- CTkInputDialog attributes completely changed
### Removed
- Removed setter and getter functions like set_text in CTkButton

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)