我一直在使用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()
您正在寻找
Gdk.ScrollDirection.UP
。您链接的文档是pygtk文档。pygtk不是gtk3。相关文档可以找到here。
相关问题 更多 >
编程相关推荐