0

I've got this line of code:

from tkinter import *

def clik(z=None):
    global T, letters, l
    letters = 0
    s = T.get("0.0",'end-1c')
    for i in s:
        if i.isalpha():
            letters += 1
    l.set('Letters: '+str(letters))

o= Tk()
letters = 0
T=Text(o, height=20, width=46)
T.pack()
T.bind("<Key>", clik)

l=StringVar()

letter=Entry(o, textvariable=l)
letter.pack(side=LEFT)
letter.configure(state="disabled")


o.mainloop()

This is supposed to track amount of letters in user input, however it won't track first letter. So if user will type "dog" it will show that user typed 2 letters. Any idea how to fix it? Thank you!

Derek Johnson
  • 717
  • 1
  • 5
  • 9

0 Answers0