
In the code above, change the PATH/OF/DIRECTORY with an appropriate path where the song files are stored. aylist = Listbox(songsframe,yscrollcommand=scrol_y.set,selectbackground="gold",selectmode=SINGLE,font=("times new roman",12,"bold"),bg="silver",fg="navyblue",bd=5,relief=GROOVE) Scrol_y = Scrollbar(songsframe,orient=VERTICAL) Songsframe = LabelFrame(self.root,text="Song Playlist",font=("times new roman",15,"bold"),bg="grey",fg="white",bd=5,relief=GROOVE) Playbtn = Button(buttonframe,text="STOPSONG",command=self.stopsong,width=10,height=1,font=("times new roman",16,"bold"),fg="navyblue",bg="pink").grid(row=0,column=3,padx=10,pady=5) Playbtn = Button(buttonframe,text="UNPAUSE",command=self.unpausesong,width=10,height=1,font=("times new roman",16,"bold"),fg="navyblue",bg="pink").grid(row=0,column=2,padx=10,pady=5) Playbtn = Button(buttonframe,text="PAUSE",command=self.pausesong,width=8,height=1,font=("times new roman",16,"bold"),fg="navyblue",bg="pink").grid(row=0,column=1,padx=10,pady=5) Playbtn = Button(buttonframe,text="PLAYSONG",command=aysong,width=10,height=1,font=("times new roman",16,"bold"),fg="navyblue",bg="pink").grid(row=0,column=0,padx=10,pady=5) Trackstatus = Label(trackframe,textvariable=self.status,font=("times new roman",24,"bold"),bg="orange",fg="gold").grid(row=0,column=1,padx=10,pady=5)īuttonframe = LabelFrame(self.root,text="Control Panel",font=("times new roman",15,"bold"),bg="grey",fg="white",bd=5,relief=GROOVE)īace(x=0,y=100,width=600,height=100) Songtrack = Label(trackframe,textvariable=ack,width=20,font=("times new roman",24,"bold"),bg="Orange",fg="gold").grid(row=0,column=0,padx=10,pady=5) Trackframe = LabelFrame(self.root,text="Song Track",font=("times new roman",15,"bold"),bg="Navyblue",fg="white",bd=5,relief=GROOVE)


# Creating the Track Frames for Song label & status label The code snippet is as follows: def _init_(self,root): Then we will create the playlist frame and add the scrollbar to it and we will add songs into the playlist. We will then Create the Track Frames for the Song label & status label and then after Insert the Song Track Label and Status Label.Īfter that, we will create the Button Frame and insert play, pause, unpause, and stop buttons into it. We will initiate pygame and pygame mixer and then declare the track variable and status variable. With the help of this constructor, we will set the title for the window and geometry for the window. Here we have the constructor and the other functions defined in the MusicPlayer class. You can add this code either after importing libraries or also at the end just before the looping of the root window and the code is as follows: root = Tk() # In order to create an empty window The Tkinter library is most popular and very easy to use and it comes with many widgets (these widgets help in the creation of nice-looking GUI Applications).Īlso, Tkinter is a very light-weight module and it is helpful in creating cross-platform applications(so the same code can easily work on Windows, macOS, and Linux)Īfter importing Libraries and modules, now it's time to create a basic window where we will add our UI elements or Tkinter widgets. We had already told you in the title of this page that we are going to use the Tkinter library, which is a standard library for GUI creation. Now we will tell you about the Libraries we will use in our code : 1. Libraries used for Music Player Application: Now we will help you to code and create a Music Player from scratch.

Then we can listen to our favorite songs. And we have to install this music player on our computer, based on the Operating system i.e Windows, Macintosh, Android, Linux, etc. So in order to listen to music, they all need a Music player(hardware or software) where they can play their favorite songs. In our daily life, we see every person has a hobby and that is listening to music. In this tutorial, we will create a Music Player Application in Python using Tkinter and Pygame module.
