python tkinter覆盖重定向;无法接收击键 (Linux) [英] python tkinter overrideredirect; cannot receive keystrokes (Linux)

查看:18
本文介绍了python tkinter覆盖重定向;无法接收击键 (Linux)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个想要全屏运行的 python tkinter 应用程序.当我取消对 overrideredirect 的注释时,窗口管理器(Gnome、Linux)将无法再将击键转发到应用程序.

I have a python tkinter application which I want to run full screen. When I uncomment overrideredirect, the window manager (Gnome, Linux) will not be able to forward keystrokes to the application anymore.

(片段,蟒蛇)

# make it cover the entire screen
w, h = master.winfo_screenwidth(), master.winfo_screenheight()
self.root.geometry("%dx%d+0+0" % (w, h))
self.root.focus_set() # <-- move focus to this widget
self.root.bind('<Escape>', self.root.quit())
#self.root.overrideredirect(True)

我找到了用于 Tcl/Tk 的 window::or 包,它应该可以解决这个错误.我将如何安装它,是否可以在我的 Python 应用程序中使用它?

I've found the window::or package for Tcl/Tk, which is supposed to resolve this bug. How would I go about installing this, and would it be possible to use it from within my python application?

http://www.binarism.com/tk/window/or/

http://www.binarism.com/tk/window-或-0.1.1.tgz

推荐答案

这适用于您使用 overrideredirect 获得全屏的用例,这有点常见:

This works for the use case where you're using overrideredirect to get fullscreen, which is somewhat common:

#self.root.overrideredirect(1)
self.root.attributes('-fullscreen', True)

这篇关于python tkinter覆盖重定向;无法接收击键 (Linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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