Professional Documents
Culture Documents
Submitted By
Name: AKSHAY KUMAR SINGH
University Roll No: 1603310026
SUBMITTED TO:
Department of Computer Science & Engineering
RAJ KUMAR GOEL INSTITUTE OF TECHNOLOGY,GHAZIABAD
1
DECLARATION
I hereby declare that the Industrial Training Report entitled “MUSIC PLAYER USING
PYTHON ” by AKSHAY KUMAR SINGH (1603310026), is an authentic record of my own
work as requirements of Industrial Training during the period from 20 JUNE 2019 to
19 JULY 2019 for the award of degree of B.Tech (Computer Science & Engineering), RKGIT,
Ghaziabad .
2
VISION & MISSION
3
PEO 4: Entrepreneur / Contribution: To develop excellent leadership quality among students
which they can use at different levels according to their experience and contribute for progress
and development in the society.
4
PO8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9: Individual and team work: Function effectively as an individual, and as member or
leader in diverse teams, and in multidisciplinary settings.
PO10: Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective
5
ACKNOWLEDGEMENT
It is our proud privilege and duty to acknowledge the kind of help and guidance received
from several people in preparation of this report. It would not have been possible to prepare
this report in this form without their valuable help, cooperation, and guidance.
First and foremost, we wish to record our sincere gratitude to Prof., Mr. Vishnu Khera for
his constant support and encouragement in the preparation of this report and for making
available library and laboratory facilities needed to prepare this report.
The seminar on “Python” was very helpful to us in giving the necessary background
information and inspiration in choosing this topic for the seminar. Their contributions and
technical support in preparing this report are greatly acknowledged.
Last but not least, we wish to thank our parents for financing our studies in this college as
well as for constantly encouraging us to learn to engineer. Their personal sacrifice in
providing this opportunity to learn engineering is gratefully acknowledged.
6
ABOUT COMPANY
Tech Mentro was founded in 2009 with a mission to create skilled Software Engineers for our
country and the world. We are here to bridge the gap between the quality of skills demanded by
industry and the quality of skills imparted by conventional institutes. At Tech Mentro, we strive
to increase student interest by providing hands-on practical training on every concept taught in
the classroom.
We create confident developers who think beyond industrial jobs and march their ideas into
self-created entrepreneurship ventures. Skill and innovative thinking give developers the
confidence to transform their ideas into real-life products and hopefully go on to build
million-dollar companies.
7
CONTENTS
Title
Declaration
Vision & Mission
Abstract
About Company
Table of contents
List of figures
Certificate
Chapter
1. INTRODUCTION……………………………………………………….………...……..12
1.1 Python Language Introduction ……………………………….……….……..……..12
1.2 Script language………………………………………………………..….…..……..12
1.3 Object-oriented programming (OOP).........................................................................13
1.4 History ……………………………………………………..…...………..…..…...13
1.5 Behind The Scene of Python………………………………………...………..…….15
2. DOWNLOAD AND INSTALLING………………………………………………...….16
2.1 Download……………………………………………………………………..……..16
2.2 Installing ……………………………………………………………………...…....18
3. PYTHON FEATURES……………..………………………………………………........26
3.1 Python Features………………………………………………………………...……26
3.2 Python graphical user interfaces (GUIs)......................................................................27
4. TKINTER……………………………………………………………………….…...........28
4.1 Tkinter……………………………………………………………………….……..….28
4.2 Tkinter Widgets………………………………………………………...…….…..…....29
4.3 Geometry Management…………………………………………...………….…...…...32
4.4 Organizing Layout And Widgets………………………………………..……….…..32
4.4.1 Grid…………………………………………………………………….…….33
8
4.5 Binding Functions ……………………………………………………….………..…..35
5. PYGAME……………………………………………………………………..………..….36
6. IMPLEMENTATION……………………………………………………....……...…......37
7. SNAPSHOTS………………………………………………………………....…..….........39
9
LIST OF FIGURES
1. Fig-1.1………………………………………………………………………………………..14
2. Fig-2.1……………………………………………………………………………...………...16
3. Fig-2.2……………………………………………………………………………...………...17
4. Fig-2.3……………………………………………………………………………...………...17
5. Fig-2.4……………………………………………………………………………...………...18
6. Fig-2.5……………………………………………………………………………...………...19
7. Fig-2.6……………………………………………………………………………...………...20
8. Fig-2.7……………………………………………………………………………...………...21
9. Fig-2.8……………………………………………………………………………...………...21
10. Fig-2.9……………………………………………………………………………...……….22
11. Fig-2.10……………………………………………………………………………...……...23
12. Fig-2.11……………………………………………………………………………...………24
13. Fig-2.12……………………………………………………………………………...……....24
14. Fig-2.13……………………………………………………………………………...……....25
15. Fig-4.1……………………………………………………………………………...………..28
16. Fig-4.2……………………………………………………………………………...……….29
17. Fig-4.3……………………………………………………………………………...………..32
18. Fig-4.4……………………………………………………………………………...………..34
19. Fig-7.1……………………………………………………………………………...………..39
10
CERTIFICATE
11
CHAPTER-1
INTRODUCTION
1.1 PYTHON
Python is a widely-used general-purpose, high-level programming language. It was initially
designed by Guido van Rossum in 1991 and developed by Python Software Foundation. It was
mainly developed for emphasis on code readability, and its syntax allows programmers to
express concepts in fewer lines of code.
Python is a programming language that lets you work quickly and integrate systems more
efficiently. Python is a widely used high-level, general-purpose, interpreted, dynamic
programming language. Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible in languages
such as C++ or Java. The language provides constructs intended to enable clear programs on
both a small and large scale.
12
web pages within a web browser, the shells of operating systems (OS), embedded systems, as
well as numerous games.
In OO programming, computer programs are designed by making them out of objects that
interact with one another. There is significant diversity in object-oriented programming, but most
popular languages are class-based, meaning that objects are instances of classes, which typically
also determines their type.
1.4 History
Python was conceived in the late 1980s by Guido van Rossum at Centrum Wiskunde
Informatica (CWI) in the Netherlands as a successor to the ABC language (itself inspired
by SETL), capable of exception handling and interfacing with the Amoeba operating
system.[8] Its implementation began in December 1989. Van Rossum continued as Python's lead
developer until July 12, 2018, when he announced his "permanent vacation" from his
responsibilities as Python's Benevolent Dictator For Life, a title the Python community bestowed
upon him to reflect his long-term commitment as the project's chief decision-maker.[46] In
January 2019, active Python core developers elected Brett Cannon, Nick Coghlan, Barry
Warsaw, Carol Willing, and Van Rossum to a five-member "Steering Council" to lead the
project.
13
Python 2.0 was released on 16 October 2000 with many major new features, including
a cycle-detecting garbage collector and support for Unicode.
Python 3.0 was released on 3 December 2008. It was a major revision of the language that is not
completely backward-compatible.[39]
Many of its major features were backported to Python 2.6.x
and 2.7.x version series. Releases of Python 3 include the 2to3 utility, which automates (at least
partially) the translation of Python 2 code to Python 3.[41]
Python 2.7's end-of-life date was initially set in 2015 then postponed to 2020 out of concern that
a large body of existing code could not easily be forward-ported to Python 3.[42] HYPERLINK
"https://en.wikipedia.org/wiki/Python_(programming_language)#cite_note-43"[43]
In January 2017, Google announced work on a
Python 2.7 to Go transcompiler to improve performance under concurrent workloads
Fig- 1.1
14
“Python is an experiment in how much freedom programmers need. Too much
freedom and nobody can read another's code; too little and expressiveness is
endangered.”
15
Chapter- 2
2.1 DOWNLOAD
If you don’t already have a copy of Python installed on your computer, you will need to open up
your Internet browser and go to the Python download page (h
ttp://www.python.org/download/).
fig-2.1
Now that you are on the download page, select which of the software builds you would like to
download. For the purposes of this article, we will use the most up to date version available
(Python 3.4.1).
16
fig-2.2
Once you have clicked on that, you will be taken to a page with a description of all the new
updates and features of 3.4.1, however, you can always read that while the download is in
process. Scroll to the bottom of the page till you find the “Download” section and click on the
link that says “download page.”
fig-2.3
Now you will scroll all the way to the bottom of the page and find the “Windows x86 MSI
installer.” If you want to download the 86-64 bit MSI, feel free to do so. We believe that even if
you have a 64-bit operating system installed on your computer, the 86-bit MSI is preferable. We
17
say this because it will still run well and sometimes, with the 64-bit architectures, some of the
compiled binaries and Python libraries don’t work well.
fig-2.4
18
fig-2.5
If you are the only person who uses your computer, simply leave the “Install for all users” option
selected. If you have multiple accounts on your PC and don’t want to install it across all
accounts, select the “Install just for me” option then press “Next.”
19
fig-2.6
If you want to change the install location, feel free to do so; however, it is best to leave it as is
and simply select next, Otherwise...
Scroll down in the window and find the “Add Python.exe to Path” and click on the small red “x.”
Choose the “Will be installed on local hard drive” option then press “Next
20
fig-2.7
Now that you have completed the installation process, click on “Finish.
fig-2.8
21
Setup the Path Variable
Begin by opening the start menu and typing in “environment” and select the option called “Edit
the system environment variables.”
Once you have the “Environment Variables” window open, direct your focus to the bottom half.
You will notice that it controls all the “System Variables” rather than just this associated with
your user. Click on “New…” to create a new variable for Python.
fig-2.9
Simply enter a name for your Path and the code shown below. For the purposes of this example,
we have installed Python 2.7.3, so we will call the path: “Pythonpath.”
22
fig-2.10
Now that we have successfully completed the installation process and added our “Environment
Variable,” you are ready to create your first basic Python script. Let’s begin by opening Python’s
GUI by pressing “Start” and typing “Python” and selecting the “IDLE (Python GUI).
23
fig-2.11
Once the GUI is open, we will begin by using the simplest directive possible. This is the “print”
directive which simply prints whatever you tell it to, into a new line. Start by typing a print
directive like the one shown in the image below or copy and paste this text then press
fig-2.12
24
Python Code Execution
Python’s traditional runtime execution model: source code you type is translated to byte code,
which is then run by the Python Virtual Machine. Your code is automatically compiled, but then
it is interpreted.
fig-2.13
25
CHAPTER - 3
PYTHON FEATURES
26
• IT supports automatic garbage collection.
• It can be easily integrated with C, C++, COM, ActiveX, CORBA, and Java.
GUI is a desktop app that helps you to interact with computers. They are used to perform
different tasks in the desktops, laptops, other electronic devices, etc.., Here, we mainly talking
about the laptops and desktops.
• GUI apps like Text-Editors are used to create, read, update and delete different types of
files.
• GUI apps like Sudoku, Chess, Solitaire, etc.., are games that you can play.
• GUI apps like Chrome, Firefox, Microsoft Edge, etc.., are used to surf the Internet.
They are some different types of GUI apps which we daily use on laptops or desktops.
27
CHAPTER -4
TKINTER
4.1 Tkinter
Tkinter is an inbuilt Python module used to create simple GUI apps. It is the most commonly
used module for GUI apps in Python.
You don't need to worry about the installation of the Tkinter module as it comes
with Python default
fig-4.1
STEPS:-
• Initialize the window manager with the Tkinter.Tk() method and assign it to a
variable window. This method creates a blank window with close, maximize and
minimize buttons.
• Rename the title of the window as you like with the window.title(title_of_the_window).
• The label is used to insert some objects into the window. Here, we are adding
a label with some text.
• pack() attribute of the widget is used to display the widget in a size it requires.
• Finally, the mainloop() method to display the window until you manually close it.
28
That's a basic program to create a simple GUI interface.
import Tkinter
window = tkinter.Tk()
# to rename the title of the window
window.title("GUI")
# pack is used to show the object in the window
label = tkinter.Label(window, text = "Hello World!").pack()
window.mainloop()
That's a basic program to create a simple GUI interface. You will see a similar window like this.
fig-4.2
29
The Canvas widget is used to draw shapes, such as lines, ovals, polygons, and rectangles, in
your application.
Checkbutton
The Checkbutton widget is used to display a number of options as checkboxes. The user can
select multiple options at a time.
Entry
The Entry widget is used to display a single-line text field for accepting values from a user.
Frame
The Frame widget is used as a container widget to organize other widgets.
Label
The Label widget is used to provide a single-line caption for other widgets. It can also
contain images.
Listbox
The Listbox widget is used to provide a list of options to a user.
Menubutton
The Menu button widget is used to display menus in your application.
Menu
The Menu widget is used to provide various commands to a user. These commands are
contained inside Menubutton.
Message
The Message widget is used to display multiline text fields for accepting values from a user.
Radiobutton
The Radiobutton widget is used to display a number of options as radio buttons. The user can
select only one option at a time.
Scale
The Scale widget is used to provide a slider widget.
Scrollbar
The Scrollbar widget is used to add scrolling capability to various widgets, such as list
boxes.
Text
The Text widget is used to display text in multiple lines.
Toplevel
The Toplevel widget is used to provide a separate window container.
Spinbox
The Spinbox widget is a variant of the standard Tkinter Entry widget, which can be used to
select from a fixed number of values.
PanedWindow
A PanedWindow is a container widget that may contain any number of panes, arranged
horizontally or vertically
LabelFrame
30
A labelframe is a simple container widget. Its primary purpose is to act as a spacer or
container for complex window layouts.
tkMessageBox
This module is used to display message boxes in your applications.
All widgets in the tkinter will have some geometry measurements. These measurements give
you to organize the widgets and their parent frames, windows, etc..,
• pack():- It organizes the widgets in the block, which mean it occupies the entire available
width. It's a standard method to show the widgets in the window
• grid():- It organizes the widgets in table-like structure. You will see details
about grid later in this tutorial.
• place():- It's used to place the widgets at a specific position you want.
Steps:-
• Frame is used to create the divisions in the window. You can align the frames as you like
with side parameter of pack() method.
Note:- The parameter of any widget method must be where to place the widget. In the below
code, we use to place in the window, top_frame, bottom_frame.
import tkinter
window = tkinter.Tk()
window.title("GUI")
The above code produces the following window, if you didn't change the above code
31
# creating 2 frames TOP and BOTTOM
top_frame = tkinter.Frame(window).pack()
window.mainloop()
#OUTPUT
fig-4.3
4.4.1 Grid
Grid is another way to organize widgets. It uses Matrix row-column concepts. Something like
this.
32
2 x 2 Matrix
00 01
10 11
EXAMPLE:-
import tkinter
window = tkinter.Tk()
window.title("GUI")
33
fig-4.4
• In the below example, when you click the button, it calls a function called say_hi.
EXAMPLE:-
window = tkinter.Tk()
window.title("GUI")
def say_hi():
window.mainloop()
34
CHAPTER-5
PYGAME
Pygame is a cross-platform set of Python modules designed for writing video games. It includes
computer graphics and sound libraries designed to be used with the Python programming
language.
Pygame was originally written by Pete Shinners to replace PySDL after its development stalled.
It has been a community project since 2000 and is released under the open source free software
GNU Lesser General Public License.
Pygame uses the Simple DirectMedia Layer (SDL) library, with the intention of allowing
real-time computer game development without the low-level mechanics of the C programming
language and its derivatives. This is based on the assumption that the most expensive functions
inside games can be abstracted from the game logic, making it possible to use a high-level
programming language, such as Python, to structure the game. Other features that SDL doesn't
have include vector math, collision detection, 2d sprite scene graph management, MIDI support,
camera, pixel-array manipulation, transformations, filtering, advanced freetype font support, and
drawing. Applications using pygame can run on Android phones and tablets with the use of
Pygame Subset for Android . Sound, vibration, keyboard, and accelerometer are supported on
Android.
35
CHAPTER- 6
IMPLEMENTATION
IMPLEMENTATION
Technologies used - Python 3.6
Python Tkinter GUI
Pygame
Mutagen
Language used - Python
def nextsong(event):
global index
index+=1
pygame.mixer.music.load(listofsongs[index])
pygame.mixer.music.play()
updatelabel()
def previoussong(event):
global index
index-=1
pygame.mixer.music.load(listofsongs[index])
pygame.mixer.music.play()
updatelabel()
def stopsong(event):
36
pygame.mixer.music.stop()
v.set("")
return songname
def updatelabel():
global index
global songname
v.set(realnames[index])
return songname
def directorychooser():
directory=askdirectory()
os.chdir(directory)
pygame.mixer.init()
pygame.mixer.music.load(listofsongs[0])
pygame.mixer.music.play()
directorychooser()
label=Label(root,text="Music Player")
label.pack()
realnames.reverse()
listbox=Listbox(root)
listbox.pack()
listofsongs.reverse()
37
for items in realnames:
listbox.insert(0,items)
realnames.reverse()
nextbutton=Button(root,text="NEXT SONG")
nextbutton.pack()
previousbutton=Button(root,text="PREVIOUS SONG")
previousbutton.pack()
stopbutton=Button(root,text="STOP SONG")
stopbutton.pack()
#button-1 means left click
#button-2 means mid click
#button-3 means right click
nextbutton.bind("<Button-1>",nextsong)
previousbutton.bind("<Button-1>",previoussong)
stopbutton.bind("<Button-1>",stopsong)
songlabel.pack()
root.mainloop()
38
CHAPTER-7
SNAPSHOTS
Snapshots
GUI – Main display window with the name of the MUSIC PLAYER USING PYTHON
fig-7.1
It is a front end of the music player using python
1.Next Song:
2.Previous Song
3.Stop Song
39
CHAPTER- 8
USES AND SCOPE
System administration
• Unix
• Web logic
• Web sphere
• GUI
• Testing scripts
• System programming
• Graphical User Interface
• Programming
• Component Integration
• Database Programming
• Gaming, Images, XML, Robot and more
40
• Google makes extensive use of Python in its web search system and
employs Python’s creator.
• Intel, Cisco, Hewlett-Packard, Seagate, Qualcomm, and IBM use Python for
hardware testing.
• ESRI uses Python as an end-user customization tool for its popular GIS
mapping products.
• The YouTube video sharing service is largely written in Python.
to be these:
• Python is object-oriented
• Structure supports such concepts as polymorphism, operation
overloading, and multiple inheritances.
• Indentation
41
42
43
CONCLUSION
This project has really been faithful and informative. It has made us learn and understand the
many trivial concepts of Python Language. As we have used python Tkinter as a GUI it provides
various controls, such as buttons, labels and text boxes to build a user-friendly application.
The fast-growing use of the internet confirms the good future and scope of the proposed project.
Finally, it has taught us a valuable lifelong lesson about the improvements and working and
interacting in a group.
44
REFERENCES
[1]- https://www.w3schools.com/python/python_intro.asp
[2]- https://www.datacamp.com/community/tutorials/gui-tkinter-python#GUI
[3]- https://www.geeksforgeeks.org/python-language-introduction/
[4]- https://www.python.org
[5]- https://www.wikipedia.org
45