Validating user input
Let's discuss input data validation in Tkinter.
Most of the applications that we have developed in our book are point and click-based (the drum machine, game of chess, and drawing application), where a validation of user input is not required.
However, data validation is a must in programs such as the phonebook application, where a user enters some data and we store it in a database.
Ignoring user input validation can be dangerous in such applications because input data can be misused for SQL injection. In general, an application in which a user can enter textual data is a good candidate for the validation of user input. In fact, not trusting user inputs is almost considered a maxim.
Wrong user input may be intentional or accidental. In either case, if you fail to validate or sanitize data, unexpected errors may occur in your program. In a worst-case scenario, user input can be used to inject harmful code that may be capable of crashing a program or wiping out an entire...