2

KeybinderGtk+3应用程序中使用 a ,但它没有得到任何组合键。这是代码:

#!/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 Jessie,我会继续运行它。xfce4

4

1 回答 1

2

当您使用GIR基于 - 的 Python 绑定时,我很确定您需要调用

Keybinder.init()

在从 Keybinder 库中调用任何其他函数之前手动进行。

(据我所知,静态python-keybinderPython 绑定会为您执行此操作,但内省绑定不会。)

于 2013-10-04T08:47:53.307 回答