[Tkinter-discuss] Tkinter on OS X generates excessive event on non-US input sequence
Alexander Uvizhev
uvizhe at yandex.ru
Sat Nov 28 16:28:29 EST 2015
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
More information about the Tkinter-discuss
mailing list