Pythoncurses.getmouse()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
curses.mousemask(1)
screen.addstr("This is a Sample Curses Script\n\n")
while True:
event = screen.getch()
if event == ord("q"): break
if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse())
curses.endwin()
if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse())
我想我应该获取单击鼠标或未单击鼠标的文本?我得到的只是 TypeError: str
。这是为什么?我缺少什么?我找不到关于这个主题的任何好的教程。谢谢。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import curses
screen = curses.initscr()
curses.noecho()
curses.curs_set(0)
screen.keypad(1)
curses.mousemask(1)
screen.addstr("This is a Sample Curses Script\n\n")
while True:
event = screen.getch()
if event == ord("q"): break
if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse())
curses.endwin()
if event == curses.KEY_MOUSE: screen.addstr(curses.getmouse())
I think I should get the text where mouse is clicked or not? All I get is TypeError: str
. Why is that? What am I missing? I couldn't find any good tutorials on this topic. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该更仔细地阅读 docs ,一切都在那里:-)
You should read the docs more carefully, it's all in there :-)