python – Converting entry() values to upper case

By Usagi

I want to make the values I type on Entry field to be automatically converted to uppercase. I have code in here that only accepts uppercase letters to be typed in the entry using validatecommand.

from tkinter import *
root = Tk()
def text(a,b,c):
    ind=int(b)
    if c == '1': #insert
        if not a[ind].isupper():
            return False
    return True
 entry = Entry(root, validate="key")
 entry['validatecommand'] = (entry.register(text),'%P','%i','%d')
 entry.pack()
root.mainloop()

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273