禁用Tkinter小部件的焦点? [英] Disable focus for tkinter widgets?

查看:117
本文介绍了禁用Tkinter小部件的焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何制作一个不会在tkinter中获得焦点的小部件?
例如,一个按钮,当我按TAB键时焦点将跳过他

How can I make a widget that will not get the focus ever in tkinter? For example, a button that when I will press TAB the focus will skip on him

推荐答案

我发现了一些是时候提供一个可行的例子了:

I have found some time to provide a working example:

import Tkinter
import tkMessageBox

root = Tkinter.Tk()

but1 = Tkinter.Button(root, text ="Button 1")
but1.pack()

butNoFocus = Tkinter.Button(root, text ="Button no focus", takefocus = 0)
butNoFocus.pack()

but2 = Tkinter.Button(root, text = "Button 2")
but2.pack()

root.mainloop()

takefocus 选项设置为0将禁用制表符对已创建按钮的聚焦。

takefocus option set to 0 will disable tab focus on created button.

这篇关于禁用Tkinter小部件的焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆