2013-10-02 71 views
1

我在Gtk+3應用程序中使用Keybinder,但它沒有得到任何組合鍵。 下面的代碼:Gtk Keybinder沒有響應

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

import gi 
gi.require_version('Keybinder', '3.0') 
from gi.repository import Keybinder 
from gi.repository import Gtk 


def test_func(data): 
    print data 


if __name__ == '__main__': 
    wnd = Gtk.Window() 
    wnd.connect('delete-event', Gtk.main_quit) 
    wnd.show_all() 

    if not Keybinder.bind('<Super>q', test_func, 'Hi there!'): 
     print "Keybinder.bind() failed." 

    Gtk.main() 

我希望要執行的程序test_func當我按下Windows+q組合鍵,但它只是什麼都不做。 如果它有所作爲,我在Debian Jessiexfce4上運行它。

回答

1

當你正在使用的GIR基於Python綁定,我敢肯定,你需要調用

Keybinder.init() 

從Keybinder庫中調用任何其他功能之前手動。

(從我所知道的情況來看,靜態的python-keybinder python綁定爲你做了這個,但是這個內省的綁定沒有。)