def stopper(): stop = get_field("stop") if stop: player.kill() return simplepage(body = "%s stopped." % song) else: f = Form() f.add_submit("stop", "Stop") return simplepage(body= ("Playing %s" % song) + f.render())
def selector(songs): global player, song chosen = get_field("select") if chosen: song = chosen player = play(song) redirect("stopper") # works with Mozilla, but not with lynx/elinks else: f = Form() f.add_single_select("select", options=songs) f.add_submit("play", "Play!") return f.render()