I want to know how the inputs to an entry widget in tkinter is validated so as to accommodate only one digit and (+/-) symbols. This widget is going to accept charge of the atom from the user. Add in this code below:
class Onlyonedigit(ttk.Entry):
def __init__(self, parent, *args, **kwargs):
super().__init__(parent, *args, **kwargs)
self.configure(
validate='all',
validatecommand=(self.register(self.validate_digit), '%P'),
)
def validate_digit(self, input):
if input.isdigit():
return True
else:
return False