Use str.isdigit() to check if the input is integer or not:
In [5]: "123".isdigit() Out[5]: True In [7]: "123.3".isdigit() Out[7]: False In [8]: "foo".isdigit() Out[8]: False
so the code will look something like this:
def get(self): c = self.a.get() d = self.b.get() if c.isdigit() and d.isdigit(): c,d=int(c),int(d) 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() elif c<255 and c>0 and d<255 and d>0: print "it worked" pass else: print "input is not an integer"
source share