8

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

sdaau
  • 36,975
  • 46
  • 198
  • 278
byteit101
  • 3,910
  • 2
  • 20
  • 29

1 Answers1

9

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.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151
  • 1
    You want to be reading in the context of the pad window rather than from the base window. A pad window is normally a temporary sub-window overlaying another window. – Ned Deily Sep 16 '12 at 03:30