当鼠标悬停在托盘图标上并滚动鼠标滚轮时,我试图让这个 python 代码做出反应,我在网上找不到任何示例。这是我到目前为止所拥有的,它对滚动滚轮没有反应......
#!/usr/bin/python
APPNAME = "My App"
ICON = "/usr/share/pixmaps/firefox.png"
import appindicator as AI
import gtk
def sayhello(item):
print "menu item selected"
def scroll(aai, ind, steps):
print "hello" # doesn't print anything
def makemenu():
' Set up the menu '
menu = gtk.Menu()
check = gtk.MenuItem('Check')
exit = gtk.MenuItem('Quit')
check.connect('activate', sayhello)
exit.connect('activate', gtk.main_quit)
menu.append(check)
menu.append(exit)
return menu
def startapp():
ai = AI.Indicator(APPNAME, ICON, AI.CATEGORY_APPLICATION_STATUS)
ai.set_status(AI.STATUS_ACTIVE)
ai.connect("scroll-event", scroll)
ai.set_menu(makemenu())
gtk.main()
startapp()
如何检测滚轮运动?