Python Tkinter Script to Play Sound Using PlaySound Library in Application Full Project For Beginners

Python Tkinter Script to Play Sound Using PlaySound Library in Application Full Project For Beginners

 

Welcome folks today in this blog post we will be playing sound inside tkinter application using playsound library. All the source code of the application will be shown below.

 

 

 

Get Started

 

 

 

In order to get started you need to install python inside our system. After this we need to install playsound library using the pip command like this

 

pip install playsound

 

Now after executing the library we need to make an app.py file and copy paste the following code

 

app.py

 

 

# importing required module 
from playsound import playsound 
from tkinter import*

root = Tk() 
root.title('GeeksforGeeks sound player') #giving the title for our window 
root.geometry("500x400") 

# making funtion 
def play(): 
    playsound('1.mp3') 

# title on the screen you can modify it  
title=Label(root,text="GeeksforGeeks",bd=9,relief=GROOVE, 
            font=("times new roman",50,"bold"),bg="white",fg="green") 
title.pack(side=TOP,fill=X) 

# making a button which triger the funtion so sound can be playeed 
play_button = Button(root, text="Play Song", font=("Helvetica", 32), 
                    relief=GROOVE, command=play) 
play_button.pack(pady=20) 

info=Label(root,text="Click on the button above to play song ", 
        font=("times new roman",10,"bold")).pack(pady=20) 
root.mainloop()

 

See also  Python 3 Tkinter Debug & Logging Data in Console Using ScrolledText Widget Example GUI Desktop App Full Project For Beginners

 

Now you need to run this python file like this

 

python app.py

 

After execution you will see the following screenshot

 

 

 

 

Leave a Reply