2011-05-04 103 views
3

我有一个python tkinter应用程序,我想要全屏运行。当我取消注释overrideredirect时,窗口管理器(Gnome,Linux)将无法将击键转发给应用程序。python tkinter overrideredirect;无法接收按键(Linux)

(片段,蟒蛇)

# 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,这是应该解决这个bug。我将如何去安装这个,并且可以在我的python应用程序中使用它?

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

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

+0

一些信息在这里:http://wiki.python.org/moin/How%20Tkinter%20can%20exploit%20Tcl/Tk%20extensions – 2011-08-17 10:48:05

回答

2

这适用于使用情况,你正在使用overrideredirect哪里得到全屏,这多少有些共同点:

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

“全屏””不是个与设置overrideredirect属性相同。 – 2012-11-26 00:02:42

+0

如果您使用'overrideredirect()'或'-fullscreen'全屏显示,前者应该包含整个“显示” - 所有显示器包括可能不在任何显示器上的区域,捕捉到一个完整的截图。 后者只接管它的屏幕 - 通常是一个监视器。 – 2015-05-08 15:14:46

0

你可能想进入赎回self.root.quit而不是self.root.quit()当你做绑定,以避免调用该函数。当你按下Escape时,可调用对象将被调用(我知道我知道)并带有事件参数。如果self.root.quit()不接受任何参数:使用拉姆达:self.root.bind('<Escape>',lambda e:self.root.quit())