import curses
def demo_win(stdscr):
curses.mousemask(-1)
stdscr.border()
while True:
e = stdscr.getch()
if e == ord("q"):
break
if e == curses.KEY_MOUSE:
_, x, y, _, _ = curses.getmouse()
stdscr.addstr(2, 2, f"x: {x:02}, y: {y:02}")
if __name__ == "__main__":
curses.wrapper(demo_win)
執行結果
Traceback (most recent call last):
File "pythonpy\first_1.py", line 17, in
curses.wrapper(demo_win)
File "Python\Python37\lib\curses_init_.py", line 73, in wrapper
stdscr = initscr()
File "Python\Python37\lib\curses_init_.py", line 30, in initscr
fd=_sys.stdout.fileno())
AttributeError: 'NoneType' object has no attribute 'fileno'
####python版本是3.7.3 電腦是windows64位元
curses函式庫是curses-2.2+utf8-cp37-cp37m-win_amd64.whl
####不知道是我安裝錯了還是程式有問題