On Thu, 24 Mar 2005 18:05:25 -0000 "Igor Riabtchuk" <[EMAIL PROTECTED]> wrote:
> Hi, > > I was playing around with Tkinter bindings and I got a question which is > probably not particularly bright. > > If I have the following code, it works because I specifically code a function > for <Alt-p> keypress: > > from Tkinter import * > > class CRED(Frame): > def __init__(self): > Frame.__init__(self) > self.txt=Text(self) > self.txt.bind('<Alt-p>', self.conv) > self.txt.pack() > self.pack() > self.txt.focus() > > def conv(self,event): > self.txt.insert(END,'t') > return 'break' > > app=CRED() > app.mainloop() > > What if instead of coding <Alt-p>, I coded <Alt-Key> - how would I implement > the function which would allow the code to determine which 'Key' was pressed > after Alt? > > Thank you. > Igor Do you mean something like this: >>> from Tkinter import * >>> r=Tk() >>> t=Text(r) >>> t.pack() >>> >>> def test(event): ... print event.keysym ... >>> t.bind('<Alt-Key>', test) '1077686180test' >>> x # Alt-x was pressed ? Michael _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor