Python 诅咒 getmouse 函数?
我正在尝试找到一种在Python中的curse模块中获取鼠标单击事件的方法。
我阅读了 http://docs.python.org/library/curses.html 并建议这样做
c == curses.getch()
if(c == curses.KEY_MOUSE):
curses.getmouse()
...
但是,这个“if 语句”似乎永远不会被触发...如果我尝试将 getmouse() 函数移到“if 语句”之外以强制它返回鼠标信息,它会返回
(devid,x,y,z,bstate) = curses.getmouse()
_curses.error: getmouse() returned ERR
还有其他想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否使用 mousemask 函数启用了鼠标事件报告,并检查了其返回值以确保它确认它实际上可以报告一些鼠标事件?根据终端(或目前的模拟器程序;-),鼠标事件报告可能全部或部分可能或不可能;无论如何,它在curses中默认是禁用的(不仅仅是在Python上,这是curses的一般思想;-)除非并且直到您使用mousemask调用显式启用它。
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.