SUMMER TRAINING
PROJECT
(5th semester 2018)
DATA SCIENCE WITH PYTHON USING GUI
SUBMITTED TO~ SUBMITTED BY~
MS. Shruty Saloni(CSE/5th
HOD CSE DEPARTMENT sem/41555102716)
ACKNOWLEDGEMENT
“Gratitude turns disappointment into lessons learned, discoveries made, alternatives explored,
and new plans set in motion.”
------ Auliq-Ice
As I begin to reflect on the magnitude of my project report, I am reminded of all the support, help
and encouragement provided to me by the members of R&D Planning Team as without their support
my project wouldn’t be ongoing. I thank the persons who inspired me to work and promoted this
unique way of learning around their surroundings. When I begin to put on paper the feelings I have
towards the people who have changed my heart, soul and thought, I am overwhelmed with emotions.
If I put it in real terms, I would call it a splendid team effort that has helped me to end my training on
high notes. My experience here has been very enriching. I sincerely hope that their guidance would be
of great help to me for the rest of the project. I show my gratitude and thankfulness:-
• To the Technical Officer for his vision, integrity and sense of qualitywhich is truly uncommon. It is
only due to his penetrating sight that my inner talent
was unveiled and has given me the confidence to face the competitive world. During my highs and lows
his words of wisdom have always been a source of inspiration forme. I am eternally grateful to you sir.
• To Ms.Shruty Ahuja for her wise and synergistic help. Her sense of responsibility, logical way of
treating situation and vision is worth of being exemplified.
DECLARATION
I hereby declare that the project work entitled “MUSIC PLAYER” is an authentic
record of my own wor as requirements of the
Industrial Training semester for the award of degree of B.TECH. (Computer Science &
Engineering), Mahaveer Swami Institute of Engineering & Technology, Sonipat
during June to July, 2018.
SALONI ARORA
CSE/5th sem/41555102716
Date: 31-08-2018
It is certified that the above statement made by the student is correct to the best of our
knowledge and belief.
Ms. Shruty Ahuja
HOD(CSE), MVSIT
ABSRACT
The Music Player was made using the basic knowledge of python and
by using its internal library class called Tkinter , using this library module the
GUI (Graphical User Interface) can be created which includes various buttons
dropdown menus and various toggle buttons etc. Python offers multiple options
for developing GUI (Graphical User Interface). Out of all the GUI methods,
tkinter is most commonly used method. It is a standard Python interface to the
Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and
easiest way to create the GUI applications. Creating a GUI using tkinter is an
easy task. Tkinter, a module in the Python standard library which fills in as an
interface to Tk, a straightforward toolbox. Making a simple GUI which handles
user input and output. GUIs often use a form of object oriented programming
which we call event-driven: the program responds to events, which are actions
that a user takes. Tkinter provides us with a variety of common GUI elements
which we can use to build our interface – such as buttons, menus and various
kinds of entry fields and display areas Tkinter’s, it is fast, and that it usually
comes bundled with Python. The combined coding and the tkinter class from
the python helped me in making the desired GUI I wanted to make for the Music Player.
CONTENT
S.No. TITLE
1. Acknowledgement
2. Certificate
3. Declaration
4. Preface
5. Organisation introduction
6. Introduction to python programming
7. Introduction to gui programming
8. Literature review
9. Program and result (source code)
10. Conclusion
11. Bibliography
INTRODUCTION TO PYTHON PROGRAMMING
Python is a dynamic, object-oriented programming language that can be used for many kinds of
software development. It offers strong support for integration with other languages and tools, comes
with extensive standard libraries, and can be learned in a few days.
What is Python?
Python is a popular programming language. It was created in 1991 by Guido van Rossum.
It is used for:
web development (server-side),
software development,
mathematics,
system scripting.
What can Python do?
Python can be used on a server to create web applications.
Python can be used alongside software to create workflows.
Python can connect to database systems. It can also read and modify files.
Python can be used to handle big data and perform complex mathematics.
Python can be used for rapid prototyping, or for production-ready
software development.
Why Python?
Python works on different platforms (Windows, Mac, Linux, Raspberry
Pi, etc).
Python has a simple syntax similar to the English language.
Python has syntax that allows developers to write programs with fewer
lines than some other programming languages.
Python runs on an interpreter system, meaning that code can be executed
as soon as it is written. This means that prototyping can be very quick.
Python can be treated in a procedural way, an object-orientated way or a
functional way.
Good to know
The most recent major version of Python is Python 3, which we shall be
using in this tutorial. However, Python 2, although not being updated
with anything other than security updates, is still quite popular.
In this tutorial Python will be written in a text editor. It is possible to
write Python in an Integrated Development Environment, such as
Thonny, Pycharm, Netbeans or Eclipse which are particularly useful
when managing larger collections of Python files.
Python Syntax compared to other programming languages
Python was designed to for readability, and has some similarities to the
English language with influence from mathematics.
Python uses new lines to complete a command, as opposed to other
programming languages which often use semicolons or parentheses.
Python relies on indentation, using whitespace, to define scope; such as the scope of loops,
functions and classes. Other programming language often use curly-brackets for this purpose.
INTRODUCTION TO GUI PROGRAMMING
Python provides various options for developing Graphical User Interfaces(GUIs).
Tkinter is the Python interface to the Tk GUI toolkit shipped with Python. There are
other Python interfaces like wxPython and jPython. wxPython is an open-source Python
interface for wxWindows. JPython is a Python port for Java which gives Python scripts seamless
access to Java class libraries on the local machine. But the most popular among these three are
Tkinter .
Tk is called Tkinter in Python, or to be precise, Tkinter is the Python interface for Tk.
Tk was developed as a GUI extension for the Tcl scripting language by John Ousterhout. The
first release was in 1991. Tk proved as extremely successful in the 1990’s, because it is easier to
learn and to use than other toolkits.
Tkinter is the standard GUI library for Python .Python when combined with combined with
Tkinter provides a fast and easy way to create GUI applications .
Tkinter provides a powerful object-oriented interface to the Tk GUI toolkit.
Creating a GUI application using Tkinter is an easy task. It can be done with the following steps.
1.Import the Tkinter module.
2.Create the GUI application main window.
3.Add one or more of the above-mentioned widgets to the GUI application.
4.Enter the main event loop to take action against each event triggered by the user.
LITERATURE REVIEW
The software used for python programming was: PYTHON 3.7.0
New syntax features:
PEP 563, postponed evaluation of type annotations.
Backwards incompatible syntax changes:
async and await are now reserved keywords.
New library modules:
contextvars: PEP 567 – Context Variables
dataclasses: PEP 557 – Data Classes
importlib.resources
New built-in features:
PEP 553, the new breakpoint() function.
Python data model improvements:
PEP 562, customization of access to module attributes.
PEP 560, core support for typing module and generic types.
the insertion-order preservation nature of dict objects has been declared to
be an official part of the Python language spec.
Programs and Results
The Code:-
import os
from tkinter.filedialog import askdirectory
import mutagen
from mutagen.id3 import ID3
from tkinter import *
root = Tk()
root.minsize(300,300)
listofsongs = []
realnames = []
v = StringVar()
songlabel = Label(root,textvariable=v,width=35)
index = 0
def directorychooser():
directory = askdirectory()
os.chdir(directory)
for files in os.listdir(directory):
if files.endswith(".mp3"):
realdir = os.path.realpath(files)
audio = ID3(realdir)
realnames.append(audio['TIT2'].text[0])
listofsongs.append(files)
mutagen.mixer.init()
mutagen.mixer.music.load(listofsongs[0])
mutagen.mixer.music.play()
directorychooser()
def updatelabel():
global index
global songname
v.set(realnames[index])
#return songname
def nextsong(event):
global index
index += 1
mutagen.mixer.music.load(listofsongs[index])
mutagen.mixer.music.play()
updatelabel()
def prevsong(event):
global index
index -= 1
mutagen.mixer.music.load(listofsongs[index])
mutagen.mixer.music.play()
updatelabel()
def stopsong(event):
mutagen.mixer.music.stop()
v.set("")
#return songname
label = Label(root,text='Music Player')
label.pack()
listbox = Listbox(root)
listbox.pack()
#listofsongs.reverse()
realnames.reverse()
for items in realnames:
listbox.insert(0,items)
realnames.reverse()
#listofsongs.reverse()
nextbutton = Button(root,text = 'Next Song')
nextbutton.pack()
previousbutton = Button(root,text = 'Previous Song')
previousbutton.pack()
stopbutton = Button(root,text='Stop Music')
stopbutton.pack()
nextbutton.bind("<Button-1>",nextsong)
previousbutton.bind("<Button-1>",prevsong)
stopbutton.bind("<Button-1>",stopsong)
songlabel.pack()
root.mainloop()
RESULT:-
EXPLANATION:-
fg=foreground color
bg=background color
1>MAIN BLANK WINDOW
From Tkinter import *
root=Tk() \\ Blank Window
theLabel=label(root,text="This is too easy")
theLabel.pack()
root.mainloop() \\ Continuos Blank Window
2> BUTTONS
fromtkinter import*
root=Tk()
nextbutton = Button(root,text = 'Next Song')
nextbutton.pack()
previousbutton = Button(root,text = 'Previous Song')
previousbutton.pack()
stopbutton = Button(root,text='Stop Music')
stopbutton.pack()
nextbutton.bind("<Button-1>",nextsong)
previousbutton.bind("<Button-1>",prevsong)
stopbutton.bind("<Button-1>",stopsong)
songlabel.pack()
button1= nextbutton = Button(root,text = 'Next Song')
button2= previousbutton = Button(root,text = 'Previous Song')
button3= stopbutton = Button(root,text='Stop Music')
3> DIRECTORY CHOOSER
def directorychooser():
directory = askdirectory()
os.chdir(directory)
for files in os.listdir(directory):
if files.endswith(".mp3"): \\SELECTING FORMAT
realdir = os.path.realpath(files)
audio = ID3(realdir)
realnames.append(audio['TIT2'].text[0])
listofsongs.append(files)
mutagen.mixer.init()
mutagen.mixer.music.load(listofsongs[0])
mutagen.mixer.music.play()
directorychooser()
3> MUTAGEN
Import mutagen
from mutagen.id3 import ID3
\\Mutagen aims to be an all purpose multimedia tagging library.
\\metadata = mutagen.[format].Open(filename)
\\A FileType is used to represent container formats which contain audio/video and tags.
In some cases, like MP4, the tagging format and the container are inseparable, while in
other cases, like MP3, the container does not know about tags and the metadata is loosely
attached to the file.
4> LISTBOX
listbox = Listbox(root)
istbox.pack()
#listofsongs.reverse()
realnames.reverse()
for items in realnames:
listbox.insert(0,items)
realnames.reverse()
#listofsongs.reverse()
\\The Listbox widget is a standard Tkinter widget used to display a list of
alternatives. The listbox can only contain text items, and all items must have
the same font and color. Depending on the widget configuration, the user can
choose one or more alternatives from the list.
\\Listboxes are used to select from a group of textual items. Depending on
how the listbox is configured, the user can select one or many items from that
list.
6> LABEL
theLabel=label(root,text="This is too easy")
theLabel.pack()
root.mainloop()
\\ A Label is a Tkinter Widget class, which is used to display text or an image.
The label is a widget that the user just views but not interacts with. The
Text displayed by this widget can be updated at any time we want. It is
Also possible to underline part of the text like to identify a keyboard shortcut
And span the text across multiple lines.
6> TKINTER WIDGETS
\\Tkinter provides various controls, such as buttons, labels and text boxes used in
GUI application. These controls are commonly called widgets. There are several types of
widgets in Tkinter. Each one will be illustrated in detail. It various top level windows and
geometry managers .
RESULT:-
Screenshots-
MAIN WINDOW (GUI)
SELECTING PLAY LIST
BUTTONS
SELECTING FOLDER
UPLOADING SONGSLIST
CONCLUSION
In this project I learned about how to create a GUI or Graphical User Interface
using python language. Since, python has many inbuilt libraries and functions.
I could use one class, called the Tkinter class to help me create the GUI for my
project Music Player, amongst the huge collection of libraries and classes in
python. Python is easy to write and understand language which does not require
any special training to recognize of what is going on in the code. A rookie who
doesn’t even know much about programming can get an idea of what the
program is about, by just reading the lines of python code as like reading a
english sentence. Python is a dynamic, object-oriented programming language
that can be used for many kinds of software development. It offers strong
support for integration with other languages and tools, comes with extensive
standard libraries, and can be learned in a few days.
Bibliography
As any development project we mostly use the official
https://www.blog.pythonlibrary.org/2010/04/20/wxpython-creating-a-simple-mp3-player/
All information we needed to use the library was here:
https://github.com/libpd/pd-for-android
https://www.youtube.com/watch?v=hm7L31bdx6g