Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44067 > unrolled thread
| Started by | alb <alessandro.basili@cern.ch> |
|---|---|
| First post | 2013-04-22 15:34 +0200 |
| Last post | 2013-04-30 07:06 -0700 |
| Articles | 6 — 6 participants |
Back to article view | Back to comp.lang.python
kbhit/getch python equivalent alb <alessandro.basili@cern.ch> - 2013-04-22 15:34 +0200
Re: kbhit/getch python equivalent Peter Otten <__peter__@web.de> - 2013-04-22 16:00 +0200
Re: kbhit/getch python equivalent Grant Edwards <invalid@invalid.invalid> - 2013-04-22 14:10 +0000
Re: kbhit/getch python equivalent Chris Angelico <rosuav@gmail.com> - 2013-04-23 01:08 +1000
Re: kbhit/getch python equivalent woooee@gmail.com - 2013-04-22 13:30 -0700
Re: kbhit/getch python equivalent xDog Walker <thudfoo@gmail.com> - 2013-04-30 07:06 -0700
| From | alb <alessandro.basili@cern.ch> |
|---|---|
| Date | 2013-04-22 15:34 +0200 |
| Subject | kbhit/getch python equivalent |
| Message-ID | <atksiaFtt00U1@mid.individual.net> |
Hi everyone, I'm looking for a kbhit/getch equivalent in python in order to be able to stop my inner loop in a controlled way (communication with external hardware is involved and breaking it abruptly may cause unwanted errors on the protocol). I'm programming on *nix systems, no need to be portable on Windows. I've seen the msvcrt module, but it looks like is for Windows only. Any ideas/suggestions? Al -- A: Because it fouls the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail?
[toc] | [next] | [standalone]
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Date | 2013-04-22 16:00 +0200 |
| Message-ID | <mailman.916.1366639243.3114.python-list@python.org> |
| In reply to | #44067 |
alb wrote: > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). > > I'm programming on *nix systems, no need to be portable on Windows. I've > seen the msvcrt module, but it looks like is for Windows only. > > Any ideas/suggestions? Curses? http://docs.python.org/dev/library/curses.html
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2013-04-22 14:10 +0000 |
| Message-ID | <kl3gbq$qp2$1@reader1.panix.com> |
| In reply to | #44067 |
On 2013-04-22, alb <alessandro.basili@cern.ch> wrote:
> I'm looking for a kbhit/getch equivalent in python in order to be able
> to stop my inner loop in a controlled way (communication with external
> hardware is involved and breaking it abruptly may cause unwanted errors
> on the protocol).
>
> I'm programming on *nix systems, no need to be portable on Windows. I've
> seen the msvcrt module, but it looks like is for Windows only.
>
> Any ideas/suggestions?
Signals, ncurses, termios.
--
Grant Edwards grant.b.edwards Yow! ANN JILLIAN'S HAIR
at makes LONI ANDERSON'S
gmail.com HAIR look like RICARDO
MONTALBAN'S HAIR!
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2013-04-23 01:08 +1000 |
| Message-ID | <mailman.924.1366643310.3114.python-list@python.org> |
| In reply to | #44067 |
On Mon, Apr 22, 2013 at 11:34 PM, alb <alessandro.basili@cern.ch> wrote: > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). Catch KeyboardInterrupt and hit Ctrl-C. ChrisA
[toc] | [prev] | [next] | [standalone]
| From | woooee@gmail.com |
|---|---|
| Date | 2013-04-22 13:30 -0700 |
| Message-ID | <2507c961-0e51-4df2-8a43-018735b3c367@googlegroups.com> |
| In reply to | #44067 |
> I'm looking for a kbhit/getch equivalent in python in order to be able to stop my inner loop in a controlled way (communication with external hardware is involved and breaking it abruptly may cause unwanted errors
A curses example
import curses
stdscr = curses.initscr()
curses.cbreak()
stdscr.keypad(1)
stdscr.addstr(0,10,"Hit 'q' to quit ")
stdscr.refresh()
key = ''
while key != ord('q'):
key = stdscr.getch()
stdscr.addch(20,25,key)
stdscr.refresh()
curses.endwin()
[toc] | [prev] | [next] | [standalone]
| From | xDog Walker <thudfoo@gmail.com> |
|---|---|
| Date | 2013-04-30 07:06 -0700 |
| Message-ID | <mailman.1178.1367330862.3114.python-list@python.org> |
| In reply to | #44067 |
On Monday 2013 April 22 06:34, alb wrote: > Hi everyone, > > I'm looking for a kbhit/getch equivalent in python in order to be able > to stop my inner loop in a controlled way (communication with external > hardware is involved and breaking it abruptly may cause unwanted errors > on the protocol). > > I'm programming on *nix systems, no need to be portable on Windows. http://code.activestate.com/search/recipes/#q=getch -- Yonder nor sorghum stenches shut ladle gulls stopper torque wet strainers.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web