how to validate number with validatecommand?

Viewed 17

I need to validate that when a value greater than 500 is entered, it generates an error indicating that the value is entered incorrectly

My code

def validarNumeroAPS(self, A_CAL):
    if A_CAL >500:
        return False.is
    else:
        messagebox.showinfo("Modificar", 'mayor a 1000.')
        return True

self.aps = StringVar()
lbl3=Label(frame2,text="A_CAL")
lbl3.place(x=3,y=105)
self.txtAps=Entry(frame2,textvariable=self.aps,validate="key", validatecommand=(self.register(self.validarNumeroAPS), "%d"))
self.txtAps.place(x=3,y=125,width=90,height=20)
0 Answers
Related