sound.py

"""Play sound from file.
   by stephan)
"""
from slut import *
from slut.tag import TextButton
import pygame

class Atlantis(World):
    def onSetup(self):
        self.showCoordinates = True
        self.name = "Play it again Slut"

        #load the sound file
        pygame.mixer.init(44100)
        snd = pygame.mixer.Sound('test.wav')
        snd.play()

        #add a play button
        def clickaction():
            snd.play()
        tb = TextButton(self, 'playbutton', '[again]', 12, 'courier', clickaction)
        tb.moveTo(120, 180)


atlantis = Atlantis()
atlantis.run()
Initiated by Stephan Hechenberger
Thanks to CADRE's 103