Re: loop until keypress (Windows XP)

2006-08-10 Thread placid
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

Re: loop until keypress (Windows XP)

2006-08-10 Thread Thomas Guettler
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

Re: loop until keypress (Windows XP)

2006-08-09 Thread placid
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

Re: loop until keypress (Windows XP)

2006-08-09 Thread Andy Terrel
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

Re: loop until keypress (Windows XP)

2006-08-09 Thread Gabriel Genellina
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

Re: loop until keypress (Windows XP)

2006-08-09 Thread Farshid Lashkari
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

loop until keypress (Windows XP)

2006-08-09 Thread 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; line = raw_input ("press q to abort") while line[0] != "q": """ keep printing text ""