滚动事件的gtk3python常量是什么

2024-09-29 09:29:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直在使用PYGObjects搜索pythongtk3的常量。特别是滚动事件的枚举常量是什么地理信息库.Gdk“object没有属性”“SCROLL”“UP”“。”。事件列在here中,并且从pygi-convert.sh不起作用 我已经包括了示例代码,可以精确地指出问题。谢谢。在

import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk

def on_destroy (widget):
    Gtk.main_quit()
    return False

def scroll_notify_event(w, e):
    print e.direction
    if e.direction == Gdk.ScrollDirection.UP:
       print "You scrolled up"
    elif e.direction == Gdk.ScrollDirection.DOWN:
       print "You scrolled down"

def event(eventbox, event):
    print("Event: %s" % event)

def create ():
    window = Gtk.Window()
    window.connect("destroy", on_destroy)
    window.add_events( Gdk.EventMask.SCROLL_MASK )

    eventbox = Gtk.EventBox()
    eventbox.connect("event", event)
    window.connect('scroll-event', scroll_notify_event)
    window.add(eventbox)

    window.show_all()


if __name__ == '__main__':
    create()
    Gtk.main()

Tags: eventgtkmaindefconnect事件windowprint