Replay: Entry validation question



Hi, Input validation in entry widget entry.connect("key_pressed",entry_key_pressed)
def entry_key_pressed(widget,event,data=None):
return not validate_currency(widget,event)
def validate_number(widget,event):
	if event.string=="" and event!=32:
		return True
	elif event.keyval >=48 and event.keyval<=57:  # 0 to 9
		return True
	else:
		return False
def validate_currency(widget,event):
	if event.string==".":
		if widget.get_text().find(".")>=0:
			return False
		elif widget.get_text().strip()=="":
			return False
		else:
			return True
	else:
return validate_number(widget,event)


I hope hope that this will be needful.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]