【问题标题】:Gtk Keybinder does not respondGtk Keybinder 没有响应
【发布时间】:2013-10-02 20:27:36
【问题描述】:

我在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 Jessiexfce4 上运行它,如果它有所作为的话。

【问题讨论】:

    标签: python linux gtk


    【解决方案1】:

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

    Keybinder.init()
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 2013-02-06
      相关资源
      最近更新 更多