0

我需要在curses中创建两个文本框并在按下时在它们之间切换Enter

当我为第二个文本框按 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) 
4

1 回答 1

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) 
于 2013-10-22T10:10:24.797 回答