March 2018
Beginner to intermediate
422 pages
10h 33m
English
Let's assume that we have a form that asks for a username. We want users to input only alphabetical or space characters in the name. Thus, a number of special characters should not be allowed, as shown in the following screenshot of the widget:

This is clearly a case for the key validation mode because we want to check whether an entry is valid after every keypress. The percent substitution that we need to check is %S because it yields the text string being inserted or deleted in the Entry widget. Therefore, the code that validates the Entry widget is as follows (see the 10.05_key_validation.py code):
import tkinter ...
Read now
Unlock full access