RPI Tkinter窗口,我想使用诸如overrideredirect之类的命令并维护输入框功能 [英] RPI Tkinter Window, I want to use a command like overrideredirect and maintain entry box functionality

查看:122
本文介绍了RPI Tkinter窗口,我想使用诸如overrideredirect之类的命令并维护输入框功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用overrideredirect或类似root.wm_attributes('-type', 'splash')之类的内容时,我的输入框无法关注用户的点击.

When using overrideredirect or something like root.wm_attributes('-type', 'splash') my entry box cannot get focus on user's click.

我正在开发一个GUI,它希望保持以前窗口的样式,并且不希望该窗口与窗口标题脱颖而出.如何摆脱RPI窗口栏,但保持输入框功能.

I am developing a GUI which I want to maintain the style of previous windows and not have this window stand out with the window header. How do I get rid of the RPI window bar but maintain entry box functionality.

推荐答案

使用启动窗口类型(仅Linux)时,您可以使用focus_force()使条目获得键盘焦点,例如将其绑定到左键.

When using the splash window type (Linux only), you can make the entry get the keyboard focus by using focus_force(), e.g. binding it to the left click.

import tkinter as tk
root = tk.Tk()
root.wm_attributes('-type', 'splash')
e = tk.Entry(root)
e.pack()
# force focus on left click:
root.bind('<1>', lambda ev: ev.widget.focus_force())
root.mainloop()

这篇关于RPI Tkinter窗口,我想使用诸如overrideredirect之类的命令并维护输入框功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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