I was wondering how I can display an error if the entry is not an integer.
I was able to make it so my code will only accept a certain range of integers, but I don’t have a way to display an error if letters are given instead. I was wondering if someone can shed some knowledge.. Thanks!
def get(self):
c = int(self.a.get())
d = int(self.b.get())
if c>255 or c<0 or d>255 or d<0 :
print c
tkMessageBox.showerror("Error2", "Please enter a value between 0-255")
self.clicked_wbbalance()
if c<255 and c>0 and d<255 and d>0:
print "it worked"
pass
Use
str.isdigit()to check whether the input is integer or not:so you code becomes something like this: