Gtk Keybinder没有响应 [英] Gtk Keybinder does not respond

查看:79
本文介绍了Gtk Keybinder没有响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Gtk+3应用程序中使用了Keybinder,但是没有任何按键组合. 这是代码:

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

我希望程序在按Windows+q键组合时执行test_func,但是它什么也没做. 如果对我有所帮助,我将在Debian Jessiexfce4上运行它.

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.

推荐答案

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

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

Keybinder.init()

在从Keybinder库调用任何其他功能之前手动进行.

manually before calling any other functions from the Keybinder library.

(据我所知,静态python-keybinder Python绑定可以为您完成此操作,但自省绑定则不行.)

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

这篇关于Gtk Keybinder没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆