I have a Tcl / Tk window with an input field in which I would like to force an uppercase character. That is, if any letters are printed, I would like them to be displayed in upper case in the input field, and not just reject the input in lower case.
I looked through the documentation for entry and Tcl / Tk wiki login validation , but I should not search in the right place, because although there are many validation examples, I cannot find an example of key input filtering to change the case.
The closest I could get is something like this:
entry .message -validate key -validatecommand { .message insert %i [string toupper "%S"] return 0 }
This causes the first character to be uppercase, but subsequent characters are not translated. In fact, the script confirmation is not called at all after the first character. If I omit the .message insert command for testing, a script confirmation is called for each character.
source share