![](https://secure.gravatar.com/avatar/8fd030b703fa8602401ff6525fa2f107.jpg?s=120&d=mm&r=g)
gquell@skequell.de wrote:
Hallo Leut,
~ versuchs mal so:
#!/usr/bin/env python # testprogramm getchar
import os, sys import termios
def getch():
~ fd = sys.stdin.fileno() ~ if os.isatty(fd):
~ old=termios.tcgetattr(fd) ~ new=termios.tcgetattr(fd) ~ new[3] = new[3] & ~termios.ICANON & ~termios.ECHO ~ new[6] [termios.VMIN] = 1 ~ new[6] [termios.VTIME] =0 ~ try: ~ termios.tcsetattr(fd, termios.TCSANOW, new) ~ termios.tcsendbreak(fd,0) ~ ch = os.read(fd,7) # vorher: 7 ~ finally: ~ termios.tcsetattr(fd, termios.TCSAFLUSH, old) ~ else: ~ ch = os.read(fd,7)
~ return(ch)
if __name__ == "__main__": ~ print "Zeichen eingeben" , ~ cc=getch() ~ for j in cc: print "%x" % ord(j), # End getchar.py
Gruß Gerhard
Sorry, da war ich wohl missverständlich. Das Problem liegt nicht in dem termios-Zweig, sondern bei dem 2. read, wenn stdin nicht als tty erkannt wird ! _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de