So I am making a calculator, I want the user to press the delete key to delete what they had written in the entry field, But When I do it also presses the decimal('.') key in the keyboard, thus activating its own function, I am using the keyboard module for this
keyboard.on_press_key("delete", lambda _:CEd())
this should activate this function:-
def CEd():
global counter
if counter ==1:
HentryPad.destroy()
counter = 0
else:
field.delete(0,END)
Clear1.config(relief=SUNKEN)
Clear1.after(58, lambda: Clear1.config(relief=RAISED))
But it also activates this function:-
def Decimals():
global counter
if counter == 1:
HentryPad.destroy()
counter=0
if field.get() != '':
if upperField.get()=='OVERFLOW!!':
upperAns.delete(0,END)
upperField.delete(0, END)
field.delete(0,END)
field.insert(END,".")
else:
upperAns.delete(0,END)
field.insert(END,".")
else:
upperAns.delete(0,END)
field.insert(0,"0.")
else:
if field.get() != '':
if upperField.get()=='OVERFLOW!!':
upperAns.delete(0,END)
upperField.delete(0, END)
field.delete(0,END)
field.insert(END,".")
else:
upperAns.delete(0,END)
field.insert(END,".")
else:
upperAns.delete(0,END)
field.insert(0,"0.")
decimal.config(relief=SUNKEN,bg="black", fg="white")
decimal.after(58, lambda: decimal.config(relief=RAISED, bg="#262626", fg="cyan"))
I have keyed the Decimals
function to the '.' key in the keyboard, but When i press the delete button on the keyboard, it also activates this function, here is the code for activating the decimals functions:-
keyboard.on_press_key(".", lambda _:Decimals())
There is nothing that is colliding with each other's function that I can spot, Pls help.