2011-05-04 102 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())