当我按 Enter
时,我需要在curses中创建两个Textbox并在它们之间切换当我按下第二个文本框的Enter键时,此代码将光标放在屏幕的左上角,我无法阻止它。
import curses
import curses.textpad as textpad
def main(screen):
"""screen is a curses screen passed from the wrapper"""
while True:
event = screen.getch()
if event :
textpad.Textbox(curses.newwin(1,13,4,0), insert_mode=True).edit()
textpad.Textbox(curses.newwin(1,13,4,16), insert_mode=True).edit()
screen.refresh()
if __name__ == '__main__':
curses.wrapper(main)
答案 0 :(得分:1)
看起来您甚至不需要致电getch()
,因为这已经足够了:
import curses
import curses.textpad as textpad
def main(screen):
"""screen is a curses screen passed from the wrapper"""
while True:
textpad.Textbox(curses.newwin(1,13,4,0), insert_mode=True).edit()
textpad.Textbox(curses.newwin(1,13,4,16), insert_mode=True).edit()
if __name__ == '__main__':
curses.wrapper(main)