On Sun, 20 Mar 2005 19:38:40 -0000
"Igor Riabtchuk" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am totally new to Python and still learning.
>
> I am looking for a way to change keyboard output within Tkinter widget - for
> example, say I press "p" and I want it to come out as "t".
>
> Could anyone possibly point me in the right direction?
>
> Igor
You can use the widget's bind() method to replace the standard callback with a
new one:
from Tkinter import *
root = Tk()
e = Entry(r)
e.pack()
def PtoT(event):
e.insert('insert', 't')
return 'break'
e.bind('<p>', PtoT)
the "return 'break'" statement prevents the event from being propagated to Tk's
standard event handler;
without it both "p" and "t" would be inserted into the Entry.
I hope this helps
Michael
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor