Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #36740

Re: Keyboard hook in linux

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <torriem@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'output': 0.04; 'say,': 0.05; '(so': 0.07; 'mouse': 0.07; 'python': 0.09; 'linux.': 0.09; 'pressing': 0.09; 'accordingly.': 0.13; 'library': 0.15; '(like': 0.15; 'properly': 0.15; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'keypress': 0.16; 'ncurses': 0.16; 'seconds.': 0.16; 'wrote:': 0.17; 'handles': 0.18; 'app': 0.19; 'keys': 0.22; 'programming': 0.23; 'idea': 0.24; 'least': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'values': 0.26; 'am,': 0.27; 'possibly': 0.27; 'updating': 0.27; 'run': 0.28; 'interactions': 0.29; 'that.': 0.30; 'e.g.': 0.30; 'url:python': 0.32; 'running': 0.32; 'certain': 0.33; 'to:addr :python-list': 0.33; 'likely': 0.33; 'text': 0.34; 'screen': 0.34; 'needed': 0.35; 'continue': 0.35; 'received:org': 0.36; 'but': 0.36; 'message-id:@gmail.com': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'should': 0.36; 'display': 0.36; 'itself': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'url:docs': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'called': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'header:Received:5': 0.40; 'help': 0.40; "you'll": 0.62; 'different': 0.63; 'felt': 0.75; 'gwt': 0.84
X-Virus-Scanned amavisd-new at torriefamily.org
Date Sun, 13 Jan 2013 09:42:01 -0700
From Michael Torrie <torriem@gmail.com>
User-Agent Mozilla/5.0 (X11; Linux i686; rv:10.0.11) Gecko/20121115 Thunderbird/10.0.11
MIME-Version 1.0
To python-list@python.org
Subject Re: Keyboard hook in linux
References <50F2DD28.9020001@nic.fi>
In-Reply-To <50F2DD28.9020001@nic.fi>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.471.1358095337.2939.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358095337 news.xs4all.nl 6926 [2001:888:2000:d::a6]:41239
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:36740

Show key headers only | View raw


On 01/13/2013 09:13 AM, K. Elo wrote:
> I am working on a small console app for linux. The idea is to display 
> some sensor values and the screen should update itself in, say, every 10 
> seconds.
> 
> The user should have the possibly to change some configurations or gwt 
> help by pressing different keys (like you can do when running e.g. 
> 'top'). In other words: the program should NOT wait for the keypress (so 
> input() is not the solution), but simply capture keypresses and act 
> accordingly. If no key is pressed, the program should continue updating 
> the screen.

'top' is built using a programming library called 'curses' or 'ncurses.'
 That's likely where you'll need to go to.  At least if you want to be
able to run properly on different terminals.  ncurses handles terminal
output including writing text at certain positions, and input/output,
and even mouse interactions if you felt you needed that.  It's
apparently part of the standard python library:
http://docs.python.org/2/library/curses.html

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Keyboard hook in linux Michael Torrie <torriem@gmail.com> - 2013-01-13 09:42 -0700

csiph-web