1
#! /usr/bin/python

import curses
import curses.textpad as textpad

try:
    mainwindow = curses.initscr()
    textpad.Textbox(mainwindow).edit()
finally:
    curses.endwin()

問題は、1 文字入力したのに 2 文字が画面に表示されることです。

4

2 に答える 2

4

エコーはデフォルトでオンになっています。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 プログラミング ページをご覧になることをお勧めします。

于 2012-09-16T06:44:21.413 に答える
2

使用curses.noecho():

import curses
import curses.textpad as textpad

try:
    mainwindow = curses.initscr()
    curses.noecho()
    textpad.Textbox(mainwindow).edit()
finally:
    curses.endwin()
于 2012-09-16T06:38:34.690 に答える