Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.041 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.00; 'cleanup': 0.07; 'python': 0.08; 'subject:python': 0.10; 'exception': 0.12; 'def': 0.13; 'atexit': 0.16; 'curses': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; 'exists': 0.18; 'seems': 0.20; 'cc:no real name:2**0': 0.20; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:2**0': 0.24; 'sat,': 0.25; 'function': 0.27; 'import': 0.27; 'url:mailman': 0.28; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.29; 'pm,': 0.29; 'example': 0.29; 'url:library': 0.31; 'thanks': 0.31; 'url:listinfo': 0.32; 'someone': 0.34; 'received:209.85.212': 0.34; 'url:python': 0.36; 'hello,': 0.37; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:docs': 0.39; 'url:org': 0.39; 'should': 0.39; 'why': 0.39; 'called': 0.40; 'received:209': 0.40; 'according': 0.61; '2011': 0.61; 'your': 0.61; 'world': 0.62; 'skip:w 30': 0.63; '31,': 0.64; 'care': 0.71; 'doing.': 0.73; 'skip:\xc2 10': 0.74; 'mag': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=rX74q8lHnrcx5555Ax6zIODbwlmjHc3uWjXnCJJVjm8=; b=OQEnwIg6dFrvuX7OjvwszMTd67SCoeF28ty/+LHfb9fxY/LAo/h1I6dl7dXr/dK1Uq rfJcV7Aaz/6RYDY3Vwhx7oCRtKQtp4L0GaS3PhCHFR0GspcGSXMXsgEdhFTn9iOrNg5j cx0w8riRSFwvwyuPUj2R0tlIWEoB0mKozwe0A= MIME-Version: 1.0 In-Reply-To: <4EFF63D9.5010100@web.de> References: <4EFF63D9.5010100@web.de> Date: Sat, 31 Dec 2011 14:52:10 -0500 Subject: Re: python curses wrapper From: Mag Gam To: Alexander Kapps Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 59 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1325361133 news.xs4all.nl 6989 [2001:888:2000:d::a6]:58046 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18275 thanks for your prompt reply. Why would I have to use atexeit? According to the documentation, curses.wrapper should handle what cleanup() should be doing. Neverthless, good to know it exists :p On Sat, Dec 31, 2011 at 2:34 PM, Alexander Kapps wrote: > On 31.12.2011 20:24, Mag Gam wrote: >> >> Hello, >> >> I have been struggling reseting the terminal when I try to do >> KeyboardInterrupt exception therefore I read the documentation for >> curses.wrapper and it seems to take care of it for me, >> http://docs.python.org/library/curses.html#curses.wrapper. >> >> Can someone please provide a Hello World example with python curses >> wrapper? >> >> tia > > > Use atexit.register() to register a cleanup function which is called when > the program exits: > > import atexit > import curses > > def cleanup(): > =C2=A0 =C2=A0curses.nocbreak() > =C2=A0 =C2=A0stdscr.keypad(0) > =C2=A0 =C2=A0curses.echo() > =C2=A0 =C2=A0curses.endwin() > > atexit.register(cleanup) > > stdscr =3D curses.initscr() > curses.noecho() > curses.cbreak() > stdscr.keypad(1) > > curses.start_color() > curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLUE) > curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK) > > stdscr.bkgd(curses.color_pair(1)) > stdscr.refresh() > > win =3D curses.newwin(5, 20, 5, 5) > win.bkgd(curses.color_pair(2)) > win.box() > win.addstr(2, 2, "Hallo, Welt!") > win.refresh() > > c =3D stdscr.getch() > > -- > http://mail.python.org/mailman/listinfo/python-list