0
def doKey(e):
	print(e.widget.get("1.0","end"))
root= Tk()
root.title('yada')
txta = Text(root, width=40, height=10)
txta.bind("<Key>", doKey)
txta.pack(side=LEFT)
root.mainloop()

Pressing a key in this text area will always output the string prior to your pressing the key. Am I missing something?

3
Contributors
4
Replies
5
Views
8 Years
Discussion Span
Last Post by pdxwebdev
0

Ok, well, what I ended up doing was just concatenating event.char to the end of widget.get(). If anyone has a better idea, please fill me.

1

hi,
i think you almost got it, here's what I have:

from Tkinter import *
def doKey(e):
	print(e.widget.get( 1.0, END + '-1c' ) + e.char )
root= Tk()
root.title('yada')
txta = Text(root, width=40, height=10)
txta.bind("<Key>", doKey)
txta.pack(side=LEFT)
root.mainloop()

Btw, that kind of behaviour is just what I need for my project, sooo thanks a lot for that dude :) hope this helps :)

0
def doKey(e):
	print(e.widget.get("1.0","end"))
root= Tk()
root.title('yada')
txta = Text(root, width=40, height=10)
txta.bind("<Key>", doKey)
txta.pack(side=LEFT)
root.mainloop()

Pressing a key in this text area will always output the string prior to your pressing the key. Am I missing something?

You could use txta.bind("<KeyRelease>", doKey)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.