gpt4 book ai didi

python curses 文本框小部件

转载 作者:太空宇宙 更新时间:2023-11-04 08:17:08 26 4
gpt4 key购买 nike

#! /usr/bin/python

import curses
import curses.textpad as textpad

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

问题是我输入了一个字符,但屏幕上显示了两个字符。

最佳答案

默认情况下回显是打开的。您需要调用 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 .

关于python curses 文本框小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12444755/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com