【发布时间】:2019-05-25 10:30:11
【问题描述】:
我想用 python-curses 检测鼠标移动事件。我不知道如何启用这些事件。我尝试如下启用所有鼠标事件:
stdscr = curses.initscr()
curses.mousemask(curses.REPORT_MOUSE_POSITION | curses.ALL_MOUSE_EVENTS)
while True:
c = stdscr.getch()
if c == curses.KEY_MOUSE:
id, x, y, z, bstate = curses.getmouse()
stdscr.addstr(curses.LINES-2, 0, "x: " + str(x))
stdscr.addstr(curses.LINES-1, 0, "y: " + str(y))
stdscr.refresh()
if c == ord('q'):
break
curses.endwin()
我只在单击、按下鼠标按钮等时获得鼠标事件,但没有鼠标移动事件。如何启用这些事件?
【问题讨论】:
标签: python python-3.x python-curses