[Tkinter-discuss] Tkinter on OS X generates excessive event on non-US input sequence

Laura Creighton lac at openend.se
Sat Nov 28 16:43:25 EST 2015


In a message of Sun, 29 Nov 2015 00:28:29 +0300, Alexander Uvizhev writes:
>Hi,
>I've found that Tkinter on Mac OS X somehow incorrectly works with events when bound sequence hit on non-US keyboard layout.
>I use Russian keyboard layout along with English and I'm trying now to arrange Undo/Redo shortcuts to work correctly independent of layout. Under Linux everything works fine from the box. Under OS X it seems like a bug and when I hit <Command-Cyrillic_ya> which is the same physical keys as <Command-z> tkinter sends excessive KeyPress event.
>Here is the test code.
>================
>from tkinter import *
>
>class TkExample(Frame):
>    def __init__(self, parent):
>        Frame.__init__(self, parent)
>        self.pack()
>        text = Text(self)
>        text.pack()
>        text.bind('<KeyPress>', self.on_kp)
>        text.bind('<<Undo>>', self.on_undo)
>
>    def on_kp(self, event):
>        print('CHAR:', event.char)
>
>    def on_undo(self, event):
>        print('UNDO')
>
>
>if __name__ == '__main__':
>    root = Tk()
>    TkExample(root)
>    root.mainloop()
>================
>
>When I run the app and hit <Command-z> I get this output:
>CHAR:
>UNDO
>
>But if I hit <Command-Cyrillic_ya> I see this:
>CHAR:  
>CHAR: z
>UNDO
>
>Under Linux in both cases I get the same output (1).
>
>Can anyone explain this? Maybe this is not a bug?
>
>-- 
>Alexander Uvizhev
>uvizhe at yandex.ru
>_______________________________________________
>Tkinter-discuss mailing list
>Tkinter-discuss at python.org
>https://mail.python.org/mailman/listinfo/tkinter-discuss

Conceivably related to this:
https://bugs.python.org/issue10973

which is filed under 'Tk bug'.  Maybe Tk got fixed but not quite enough
fixed?

Laura


More information about the Tkinter-discuss mailing list