2013-10-22 89 views
0

我需要在詛咒創建兩個文本框,當我按下輸入多個文本框

這個代碼把光標在屏幕的左上角時,我按第二進入它們之間進行切換文本框和我無法阻止它。

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) 

回答

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) 
+0

的問題是,我需要按Enter第三次去的第一個文本框,這是我不喜歡 – Hassen

+0

@metro,我更新了我的答案,因爲修改循環似乎更好。 – Nykakin