#! /usr/bin/python
import curses
import curses.textpad as textpad
try:
mainwindow = curses.initscr()
textpad.Textbox(mainwindow).edit()
finally:
curses.endwin()问题是我输入了一个字符,但屏幕上显示了两个字符。
发布于 2012-09-16 14:44:21
默认情况下,回显处于启用状态。下线需要调用noecho。
#!/usr/bin/env python
import curses
import curses.textpad as textpad
try:
mainwindow = curses.initscr()
# Some curses-friendly terminal settings
curses.cbreak(); mainwindow.keypad(1); curses.noecho()
textpad.Textbox(mainwindow).edit()
finally:
# Reverse curses-friendly terminal settings
curses.nocbreak(); mainwindow.keypad(0); curses.echo()
curses.endwin()(该脚本已在Python 2.7上进行了测试)。我建议你去看看curses programming page。
发布于 2012-09-16 14:38:35
使用curses.noecho():
import curses
import curses.textpad as textpad
try:
mainwindow = curses.initscr()
curses.noecho()
textpad.Textbox(mainwindow).edit()
finally:
curses.endwin()https://stackoverflow.com/questions/12444755
复制相似问题