Gtk Keybinder does not respond

左心房为你撑大大i 提交于 2020-01-24 15:37:10

问题


I'm using a Keybinder in a Gtk+3 application, but it doesn't get any key combinations. Here's the code:

#!/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()

I expect the program to execute test_func when I press Windows+q key combo, but it just does nothing. I'm running it on Debian Jessie with xfce4 if it makes a difference.


回答1:


As you're using the GIR-based Python bindings, I'm pretty sure you need to call

Keybinder.init()

manually before calling any other functions from the Keybinder library.

(From what I can tell, the static python-keybinder Python bindings do this for you, but the introspected bindings do not.)



来源:https://stackoverflow.com/questions/19146239/gtk-keybinder-does-not-respond

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!