import pygame from tkinter import * def play_music(): pygame.mixer.music.load('exercises/background.wav') pygame.mixer.music.play() def pause_music(): pygame.mixer.music.pause() def unpause_music(): pygame.mixer.music.unpause() def play_sound_effect(): pygame.mixer.Sound.play(sound_effect) pygame.init() sound_effect = pygame.mixer.Sound('exercises/crash.wav') root = Tk() root.geometry('180x200') myframe = Frame(root) myframe.pack() mylabel = Label(myframe, text = "Pygame Mixer") mylabel.pack() button1 = Button(myframe, text = "play music", command = play_music, width = 15) button1.pack(pady = 5) button2 = Button(myframe, text = "play sound", command = play_sound_effect, width = 15) button2.pack(pady = 5) button3 = Button(myframe, text = "unpause Music", command = unpause_music, width = 15) button3.pack(pady = 5) button4 = Button(myframe, text = "pause music", command = pause_music, width = 15) button4.pack(pady = 5) root.mainloop()