I'm trying to find a way to get mouse click event in curse module in Python.
I read the document on http://docs.python.org/library/curses.开发者_如何学编程html and it suggested to do
c == curses.getch()
if(c == curses.KEY_MOUSE):
curses.getmouse()
...
However, this "if statement" seems to never get triggered... and if I tried to move the getmouse() function outside of "if statement" to force it to return the mouse information, it return
(devid,x,y,z,bstate) = curses.getmouse()
_curses.error: getmouse() returned ERR
Any other thought?
Have you enabled mouse-event reporting with the mousemask function, and checked its return value to make sure it confirms that it can actually report some mouse-events? Depending on the terminal (or emulator program for one, these days;-), mouse event reporting may or may not be possible, in whole or in part; and in any case, it's disabled by default in curses (not just on Python, that's a curses general idea;-) unless and until you explicitly enable it with the mousemask
call.
精彩评论