2012-09-15 60 views
5

我似乎無法讓ncurses pad在Python(2.6,2.7和3.2)中工作。使用代碼直接關閉http://docs.python.org/howto/curses.html我什至不能得到它的工作。非填充代碼完美地工作。(n)curses pad in python not working

import curses 

def func(scr): 
    pad = curses.newpad(100, 100) 
    pad.addstr(0,0, "Testing") 

    # Displays a section of the pad in the middle of the screen 
    pad.refresh(0,0, 5,5, 10,10) 

    scr.refresh() 
    scr.getch() 

if __name__ == '__main__': 
    curses.wrapper(func) 

問題是什麼?刪除墊(和更換墊scr)工作正常

+0

您使用的平臺是? –

+0

Linux,Ubuntu 12.04 for 2.7和3.2以及Debian 6.0 for 2.6 – byteit101

回答

4

您正在覆蓋墊。嘗試從pad對象中調用getch方法,而不是主窗口對象scr,並刪除scr.refresh

+0

改變getch的功能是什麼? – byteit101

+0

您想要在填充窗口的上下文中閱讀,而不是從基本窗口閱讀。填充窗口通常是覆蓋另一個窗口的臨時子窗口。 –