我在 Gtk+3
应用程序中使用 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()
我希望当我按下 Windows+q
组合键时程序会执行 test_func
,但它什么也没做。
如果有影响的话,我会在 Debian Jessie
上使用 xfce4
运行它。
最佳答案
当您使用基于 GIR
的 Python 绑定(bind)时,我很确定您需要调用
Keybinder.init()
在从 Keybinder 库调用任何其他函数之前手动调用。
(据我所知,静态 python-keybinder
Python 绑定(bind)会为您执行此操作,但内省(introspection)绑定(bind)不会。)
关于python - Gtk Keybinder 没有响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19146239/