GUI to extract lyrics from a song Using Tkinter in Python
GUI:
A graphical interface (GUI) is a user interface that lets users interact with electronic devices like computers and smartphones by using menus, icons, and other visual cues (graphics). In contrast to text-based interfaces, which only display data and commands as text, GUIs visualize information and related user controls. A cursor, trackball, stylus, or thumb on a touch screen are all pointing devices that can be used to communicate with GUI representations. The first text interface between a human and a computer operated using keyboard input and a prompt.
One of the most significant factors that increased the usability of computer and digital technologies for common, less tech-savvy users is likely the development and widespread adoption of GUIs. GUIs are intuitive enough that even relatively unskilled employees without programming experience can use them. Because they are always designed with the user in mind rather than being primarily machine-centred, they have become the standard in software application programming.
The user is provided with information using manipulable visual widgets that don't require command-line input. These interface components respond to the user's interactions per the pre-programmed script, assisting each user's action. Since many GUIs represent text and graphical elements in standard formats, it is possible for programs using the same GUI software to share data. As it is patched and developed, the same software application or OS version may present distinct or marginally distinct GUIs. The appearance of an application may change depending on user needs or to enhance the user experience, even if the application's core functionality and functions remain unchanged, as was the case with the various Windows versions over time.
Commands were entered at the DOS prompt to ask for responses from a desktop. These commands' usage and the requirement for precise spelling led to an unwieldy and ineffective user interface.
Advantages of GUI:
Quick and easy access to any screen area allows for full-screen interaction. You merely click a button or an icon to invoke the necessary function. The general public now has access to a wide range of systems for daily use, regardless of experience or knowledge, thanks to the simplicity of GUIs. Additionally, Tkinter provides access to the widgets' geometric configuration, which can arrange the widgets in the parent windows.
Disadvantages of GUI:
Due to the numerous menus, some tasks may take a while to complete. The Help file must be used to search for hidden commands. Applications with a GUI require more RAM to operate. Compared to different interface types, it consumes more processing power.
Tkinter:
The standard Python technique for building Graphical User Interfaces (GUIs) is Tkinter, which is included in all popular Python distributions. The only framework included in the Python standard library is this one. On top of Tk, this Python framework serves as a thin object-oriented layer that provides access to the Tk toolkit. The Tk toolkit is a cross-platform set of "graphical control elements," also called widgets, used to build application interfaces. This framework gives Python users a quick and easy way to build GUI elements with the Tk toolkit's widgets. In a Python application, Tk widgets can be used to create buttons, menus, data fields, etc.
Tkinter bridges the gap between Python's execution model and Tcl's, built around cooperative multitasking. Like Python, Tcl is an interpreted dynamic programming language. Although it is an overall programming language that can be used independently, it is most frequently used in C programs as a scripting motor or as an interaction with the Tk toolbox. The Tcl library has a C interface that enables users to add custom Tcl or C commands, run Tcl commands and scripts, and manage one or more Tcl interpreter instances. Each interpreter has a queue for events that can be used to send and process events.
Syntax:
from tkinter import *
from tkinter import ttk
CODE:
from tkinter import *
from lyrics_extractor import SongLyrics
def get_lyrics():
extract_lyrics = SongLyrics(
"Aerwerwefwdssdj-nvN3Oq0oTixw", "werwerewcxzcsda")
temp = extract_lyrics.get_lyrics(str(e.get()))
res = temp['lyrics']
result.set(res)
master = Tk()
master.configure(bg='light grey')
result = StringVar()
Label(master, text="Enter Song name : ",
bg="light grey").grid(row=0, sticky=W)
Label(master, text="Result :",
bg="light grey").grid(row=3, sticky=W)
Label(master, text="", textvariable=result,
bg="light grey").grid(row=3, column=1, sticky=W)
e = Entry(master, width=50)
e.grid(row=0, column=1)
b = Button(master, text="Show",
command=get_lyrics, bg="Blue")
b.grid(row=0, column=2, columnspan=2,
rowspan=2, padx=5, pady=5,)
mainloop()
CODE EXPLANATION:
Importing a single library which is tkinter. In the tkinter module there is a lyrics_extractor which is used to extract the song lyrics; in lyrics_extractor it includes all the lyrics which are predefined in it when we give a song name as input it extracts the entire lyrics of the song and gives the every line of lyrics in a new line as a output.
OUTPUT:
