Python: How do I code to make a button do something else if pressed a second time?
Question: I have this music program, so when I click a button it starts playing music.
When I press it again, I want it to stop the music, but instead it plays the
same beat on top of the first one. How do I get around doing this?

EDIT: Oops, silly me, forgot about the details. I use Python 2.7,
wxFormBuilder, and Easy Eclipse. Here's the code:

    
    
    import gui
    import wx
    import wx.media
    import pygame
    import tkFileDialog
    
    class MainFrame( gui.GUI_MainFrame):
        def __init__( self, parent ): #Definerar KunddatabasMainFrame
            pygame.init()
            gui.GUI_MainFrame.__init__( self, parent ) #Initierar MainFrame f�nstret
            self.sound1=pygame.mixer.Sound('beat1.wav')
            self.sound2=pygame.mixer.Sound('beat2.wav')
            self.recording = False
    
        def evtBrowse1(self, evt):
            tkFileDialog.askopenfilename()
    
        def evtSoOne(self, evt):
            self.sound1.play(loops=-1)
    


Answer: It would be easier to help if you posted some code. But think about adding an
`AlreadyPlaying` variable and check it in your function using an `if`
statement.

