user2772570
user2772570

Reputation: 25

Gtk Keybinder does not respond

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.

Upvotes: 2

Views: 568

Answers (1)

Tristan Brindle
Tristan Brindle

Reputation: 16824

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.)

Upvotes: 2

Related Questions