简体   繁体   English

覆盖Python Tkinter中的默认选项卡行为

[英]Overriding default tab behaviour in Python Tkinter

I am writing an application in Python using Tkinter to manage my GUI. 我正在使用Tkinter编写Python应用程序来管理我的GUI。

There is a text entry box on which I am trying to implement an autocompletion function which will bind to the Tab key. 我有一个文本输入框,我试图实现一个自动完成功能,它将绑定到Tab键。

I have bound the tab key to my entry box, but when I press tab, the program attempts to cycle between GUI elements. 我已将Tab键绑定到我的输入框,但是当我按Tab键时,程序会尝试在GUI元素之间循环。

How do I override this default behavior so that the GUI will only carry out my specified command on the key press? 如何覆盖此默认行为,以便GUI仅在按键上执行指定的命令?

Thanks 谢谢

Return 'break' at the end of your event handler. 在事件处理程序结束时返回'break' It interrupts event propagation. 它会中断事件传播。

def my_tab_handler(event):
    ... # handle tab event
    return 'break' # interrupts event propagation to default handlers

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM