TKinter文本/条目小部件在按F1(OSX)时显示奇怪的字符

问题描述 投票:0回答:1

当焦点位于文本小部件上时按F1键(或其他功能键,如F5,F6等),会将这些奇怪的问号字符放在文本小部件上。

禁用打印这些字符的最佳方法是什么?

enter image description here

我可以绑定到KeyPress事件以检测它们并避免打印它,但是想知道是否有更好的方法可以做到这一点。一切在Windows 10和Linux上都能正常运行,我只在Mac OSX上看到此问题。在Mac Mojave上使用Python 3.7。

这是我的解决方法:

self.function_key_sym_re = re.compile(r'^F\d+$')
self.editor_text.bind("<KeyPress>", self.on_editor_key_press)

. . . 
def on_editor_key_press(self, event):            
    if self.function_key_sym_re.match(event.keysym): 
        return "break"

python tkinter
1个回答
0
投票

在Mac上,F键默认绑定到系统功能。要使用F键,您需要按下“ Fn”键和F键。

可以输入问号吗?

© www.soinside.com 2019 - 2024. All rights reserved.