I have a challenge to be done in tkinter, customtkinter and as you can see in the code I made a function that when pressing the number "0" on the keyboard the function is called and the number is printed inside the Entry, but there is a problem. The button's animation is not executed, and it would be interesting if this happens so that the code is more complete, however, I don't know how to do that.
import customtkinter as CTk
from tkinter import *
import keyboard
class MainWindow():
def __init__(self) -> None:
self.layout_0 = Tk()
self.layout_1 = Frame(self.layout_0)
self.layout_1.grid()
self.display_0_var = StringVar()
self.display_0 = CTk.CTkEntry(master=self.layout_1, font=('Arial', 50),
textvariable=self.display_0_var, width=294,
justify='right', corner_radius=0, border_width=0, state='readonly')
self.display_0.grid(column=0, row=0)
button = CTk.CTkButton(master=self.layout_0, command=self.input)
button.place(x=10, y=100)
keyboard.on_press_key('0', self.input_key)
self.layout_0.mainloop()
def input(self):
current = self.display_0.get()
new = current + '0'
self.display_0_var.set(new)
...
def input_key(self, events):
self.input()
MainWindow()