Thomas Guettler wrote:
> Am Wed, 09 Aug 2006 22:19:24 -0700 schrieb placid:
>
> > Hi all,
> >
> >
> > Im using the cmd module and i have command that loops and keeps on
> > printing text, what i want to be able to do is loop until the user
> > presses a particular key, say Q/q ? I tried the follow
Am Wed, 09 Aug 2006 22:19:24 -0700 schrieb placid:
> Hi all,
>
>
> Im using the cmd module and i have command that loops and keeps on
> printing text, what i want to be able to do is loop until the user
> presses a particular key, say Q/q ? I tried the following code;
>
There is a portable get
Gabriel Genellina wrote:
> At Thursday 10/8/2006 02:19, placid wrote:
>
> >chr = sys.stdin.read(1)
> >while chr != "q":
> > """ keep printing text """
> > chr = sys.stdin.read(1)
> >
> >but again this blocks too.
> >
> >is there a way to do this, wait for user input but dont block? I could
If you did want a linux version you could just make people send a
KeyboardInterupt.
try:
print "Press ^C to stop"
loop
except KeyboardInterrupt:
some stop action or just pass
--
http://mail.python.org/mailman/listinfo/python-list
At Thursday 10/8/2006 02:19, placid wrote:
chr = sys.stdin.read(1)
while chr != "q":
""" keep printing text """
chr = sys.stdin.read(1)
but again this blocks too.
is there a way to do this, wait for user input but dont block? I could
use a thread that just does the previous code block
placid wrote:
> is there a way to do this, wait for user input but dont block?
Hi,
The msvcrt module should do what you want. Here is a sample:
import msvcrt
chr = 0
while chr != 'q':
""" keep printing text """
if msvcrt.kbhit():
chr = msvcrt.getch()
Keep in mind that this
Hi all,
Im using the cmd module and i have command that loops and keeps on
printing text, what i want to be able to do is loop until the user
presses a particular key, say Q/q ? I tried the following code;
line = raw_input ("press q to abort")
while line[0] != "q":
""" keep printing text ""