Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18274
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <alex.kapps@web.de> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'cleanup': 0.07; 'python': 0.08; 'exception.': 0.09; 'message- id:@web.de': 0.09; 'oh,': 0.09; 'subject:python': 0.10; 'exception': 0.12; 'def': 0.13; 'curses': 0.16; 'exit()': 0.16; 'received:10.249': 0.16; 'wrote:': 0.18; 'seems': 0.20; 'header :In-Reply-To:1': 0.22; 'from:addr:web.de': 0.23; 'function': 0.27; 'import': 0.27; 'missed': 0.28; 'sorry,': 0.29; 'print': 0.29; 'example': 0.29; 'url:library': 0.31; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.34; 'someone': 0.34; 'try:': 0.34; 'url:python': 0.36; 'except': 0.37; 'hello,': 0.37; 'url:docs': 0.39; 'received:de': 0.39; 'url:org': 0.39; 'called': 0.40; 'to:addr:python.org': 0.40; 'world': 0.62; 'skip:w 30': 0.63; 'here': 0.65; 'care': 0.71; 'mag': 0.84 |
| Date | Sat, 31 Dec 2011 20:49:55 +0100 |
| From | Alexander Kapps <alex.kapps@web.de> |
| User-Agent | Mozilla/5.0 (X11; U; Linux i686; de-DE; rv:1.9.2.21) Gecko/20110831 Thunderbird/3.1.13 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: python curses wrapper |
| References | <CAPG7Zsg1w=3tpyAiwRieriC7EBAMgXjKLd3=s7j6W_3rkdcHAg@mail.gmail.com> <4EFF63D9.5010100@web.de> |
| In-Reply-To | <4EFF63D9.5010100@web.de> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Provags-ID | V02:K0:l8h31vbLkCQXc+ZOFWc7y1AIzrcNPTR0YjR3kguj8TV 5QsIznW9h/pTQ7h8qNeGC3FdxSUzuNMmBiU40sXDVAGtjCsZsg FF9JWOUPQT46/MappS3pJWQExhY6Tx3GlnvExqwYP2f2mH4PIX x/t34ZNifP0PEOeoBQRQPNr+ngub+AfwDr6GgjTuPs46S0qOvu vf0rdTzr57dGUMJmGXtHA== |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4279.1325360980.27778.python-list@python.org> (permalink) |
| Lines | 44 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1325360980 news.xs4all.nl 6903 [2001:888:2000:d::a6]:44116 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:18274 |
Show key headers only | View raw
On 31.12.2011 20:34, 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:
Oh, sorry, I missed the curses.wrapper() part. Here is an example:
import curses
def main(screen):
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLUE)
curses.init_pair(2, curses.COLOR_YELLOW, curses.COLOR_BLACK)
screen.bkgd(curses.color_pair(1))
screen.refresh()
win = curses.newwin(5, 20, 5, 5)
win.bkgd(curses.color_pair(2))
win.box()
win.addstr(2, 2, "Hallo, Welt!")
win.refresh()
c = screen.getch()
try:
curses.wrapper(main)
except KeyboardInterrupt:
print "Got KeyboardInterrupt exception. Exiting..."
exit()
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: python curses wrapper Alexander Kapps <alex.kapps@web.de> - 2011-12-31 20:49 +0100
csiph-web