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


Groups > de.comp.lang.python > #4435

Re: [Python-de] Warten auf user-input, aber nicht zu lange

Path csiph.com!aioe.org!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!fu-berlin.de!uni-berlin.de!not-for-mail
From Christopher Arndt <chris@chrisarndt.de>
Newsgroups de.comp.lang.python
Subject Re: [Python-de] Warten auf user-input, aber nicht zu lange
Date Tue, 26 Apr 2016 16:13:44 +0200
Lines 71
Message-ID <mailman.107.1461680058.32212.python-de@python.org> (permalink)
References <571F3E6B.4090402@fam-goebel.de> <571F7798.4060306@chrisarndt.de>
Mime-Version 1.0
Content-Type multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ePenvI5fwuxEOVS1nuNot9ALMX3lBiodp"
X-Trace news.uni-berlin.de azwN/Islo8EBR38cBtjshQExQzBQ+mKsFP7X3ruBvMBA==
Return-Path <chris@chrisarndt.de>
X-Original-To python-de@python.org
Delivered-To python-de@mail.python.org
X-Virus-Scanned Debian amavisd-new at mx1.0x20.eu
Openpgp id=F0BA1EAE86651989C0A1C9901E0D97B33A4E1F31
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1
In-Reply-To <571F3E6B.4090402@fam-goebel.de>
X-BeenThere python-de@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id Die Deutsche Python Mailingliste <python-de.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-de>, <mailto:python-de-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-de/>
List-Post <mailto:python-de@python.org>
List-Help <mailto:python-de-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-de>, <mailto:python-de-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <571F7798.4060306@chrisarndt.de>
X-Mailman-Original-References <571F3E6B.4090402@fam-goebel.de>
Xref csiph.com de.comp.lang.python:4435

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

Am 26.04.2016 um 12:09 schrieb Ulrich Goebel:
> Wie schreibt man eine solche Funktion ENTER_gedrueckt()?

Dazu musst du die Konsoleneingabe abfragen, ohne zu blocken. Dazu gibt
es in Python keine eingebaute Funktion. Normalerweise benutzt man für so
etwas ein GUI (Tkinter, PyGTK, PyQt, pygame, etc.) oder
Konsolen-Framework (curses), das die plattformabhängigen Methoden dafür
kapselt.

Ansonsten und wenn nur POSIX-Systeme unterstützt werden müssen, hilft
dir diese Funktion:

https://gist.github.com/SpotlightKid/816e12fc9dd7003f5c6b41ce0a633de2

(Die Zeitsteuerung überlasse ich dir zur Übung ;))

Unter Windows gibt es die Funktionen 'kbhit' und 'getch' im
msvcrt-Modul, mit denen man sich eine ähnliche Lösung basteln kann:

https://docs.python.org/3/library/msvcrt.html


Chris

Back to de.comp.lang.python | Previous | Next | Find similar


Thread

Re: [Python-de] Warten auf user-input, aber nicht zu lange Christopher Arndt <chris@chrisarndt.de> - 2016-04-26 16:13 +0200

csiph-web