Taking Input in Python

phokur

n00b
Joined
Sep 3, 2007
Messages
44
I'm trying to make a winamp station selector in Python and it's working, I just don't like having to hit enter after each selection. Is there any way to do that in Python?
Code:
# Needs to be in winamp folder

while True:
  import os

  def X(): print os.system('winamp.exe http://sc12.1.fm:7024')
  def HighVoltage(): print os.system('winamp.exe http://sc12.1.fm:7058')
  def Trance(): print os.system('winamp.exe http://sc8.1.fm:7012')
  def errhandler (): print ""

  takeaction = {
    "1": X,
    "2": HighVoltage,
    "3": Trance}

  station = raw_input("Please enter a station: ")
  takeaction.get(station,errhandler)()
 
Figured it out used msvcrt:
Code:
# Needs to be in winamp folder
import os
import msvcrt

while 1:
    char = msvcrt.getch()
    if char == chr(27):
        break
    if char == chr(49):
        print os.system('winamp.exe http://sc12.1.fm:7024')
    if char == chr(50):
        print os.system('winamp.exe http://sc12.1.fm:7058')
    if char == chr(51):
        print os.system('winamp.exe http://sc8.1.fm:7012')
 
Back
Top