[Tutor] curses class problem
Sammy Mannaert
nstalkie@tvd.be
Wed, 25 Jul 2001 19:16:06 +0200
hi,
i'm trying to build a curses class wrapper (to abstract a
screen). i'm not an experienced curses user though.
i was trying to do a __init__ and a __del__ function and
already it fails :)
Exception exceptions.AttributeError: "'None' object has no attribute 'echo'" in <method
Screen.__del__ of Screen instance at 0x819c92c> ignored
i have programmed in python quite some times before but
i can't figure out why this doesn't work ...
it DOES work however if i add self.curses = curses and call
every curses function as 'self.curses.rest_of_the_function'
====== the code ======
# abstraction of a screen
import curses
class Screen:
def __init__(self):
self.stdscr = curses.initscr()
curses.noecho()
curses.cbreak()
self.stdscr.keypad(1)
def __del__(self):
self.stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
# testroutine
if __name__ == "__main__":
screen = Screen()
===== end =====
any help/explenation is appreciated :)