(n)curses pad in python not working

柔情痞子 提交于 2020-01-01 10:05:25

问题


I cannot seem to get ncurses pads to work in python (2.6, 2.7, and 3.2). Using code directly off of http://docs.python.org/howto/curses.html I even cannot get it to work. Non-pad code works perfectly.

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)

What can the issue be? Removing the pad (and changing pad to scr) works fine


回答1:


You're overwriting the pad. Try calling the getch method from the pad object instead of the main window object scr and delete the scr.refresh.



来源:https://stackoverflow.com/questions/12442965/ncurses-pad-in-python-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!