# Importing the libraries
from tkinter import *
import pygame
# initializing the pygame
pygame.init()
root = Tk()
# Setting the title and geometry
root.title("Music Box")
root.geometry("1352x700+0+0")
root.configure(background="white")
# creating the Frames
abc = Frame(root, bg="powder blue", bd=20, relief=RIDGE)
abc.grid()
abc1 = Frame(abc, bg="powder blue", bd=20, relief=RIDGE)
abc1.grid()
abc2 = Frame(abc, bg="powder blue", relief=RIDGE)
abc2.grid()
abc3 = Frame(abc, bg="powder blue", relief=RIDGE)
abc3.grid()
str = StringVar()
str.set("Just like Music")
#Functions for sound
def value_Cs():
str.set("C#")
sound = pygame.mixer.Sound("C#.wav")
sound.play()
def value_A():
str.set("A")
sound = pygame.mixer.Sound("A.wav")
sound.play()
def value_B():
str.set("B")
sound = pygame.mixer.Sound("B.wav")
sound.play()
def value_C():
str.set("C")
sound = pygame.mixer.Sound("C.wav")
sound.play()
def value_Bb():
str.set("Bb")
sound = pygame.mixer.Sound("Bb.wav")
sound.play()
def value_Gs():
str.set("G#")
sound = pygame.mixer.Sound("G#.wav")
sound.play()
def value_Ds():
str.set("D#")
sound = pygame.mixer.Sound("D#.wav")
sound.play()
def value_Fs():
str.set("F#")
sound = pygame.mixer.Sound("F#.wav")
sound.play()
def value_G():
str.set("G")
sound = pygame.mixer.Sound("G.wav")
sound.play()
def value_D():
str.set("D")
sound = pygame.mixer.Sound("D.wav")
sound.play()
def value_E1():
str.set("E1")
sound = pygame.mixer.Sound("E.mp3")
sound.play()
def value_E():
str.set("E")
sound = pygame.mixer.Sound("E!.mp3")
sound.play()
def value_F():
str.set("F")
sound = pygame.mixer.Sound("F!.mp3")
sound.play()
def value_F1():
str.set("F1")
sound = pygame.mixer.Sound("F.mp3")
sound.play()
def value_C1():
str.set("C1")
sound = pygame.mixer.Sound("C1.mp3")
sound.play()
def value_D1():
str.set("D1")
sound = pygame.mixer.Sound("D1.mp3")
sound.play()
def value_Cs1():
str.set("C#1")
sound = pygame.mixer.Sound("C#1.mp3")
sound.play()
def value_Ds1():
str.set("C#1")
sound = pygame.mixer.Sound("D#1.mp3")
sound.play()
# Label
Label(abc1, text="Piano Musical Keys", font=("arial", 25, "bold"), padx=8, pady=8, bd=4, width=59, bg="powder blue",
fg="white", height=1,
justify=CENTER).grid(row=0, column=0, columnspan=11)
display = Entry(abc1, textvariable=str, font=("arial", 18, "bold"), width=35, bd=34, bg="powder blue", fg="black",
justify=CENTER).grid(row=1, column=5, pady=1)
# Buttons for keynotes
btnCs = Button(abc2, height=6, width=4, bd=4, text="C#", font=("arial", 18, "bold"), bg="black", fg="white",
command=value_Cs)
btnCs.grid(row=0, column=0, padx=5, pady=5)
btnDs = Button(abc2, height=6, width=4, bd=4, text="D#", font=("arial", 18, "bold"), bg="black", fg="white",
command=value_Ds)
btnDs.grid(row=0, column=1, padx=5, pady=5)
btnSpace1 = Button(abc2, state=DISABLED, height=6, width=2, bg="powder blue", relief=FLAT)
btnSpace1.grid(row=0, column=3, padx=0, pady=0)
btnFs = Button(abc2, height=6, width=4, bd=4, text="F#", font=("arial", 18, "bold"), bg="black", fg="white",
command=value_Fs)
btnFs.grid(row=0, column=4, padx=5, pady=5)
btnGs = Button(abc2, height=6, width=4, bd=4, text="G#", font=("arial", 18, "bold"), bg="black", fg="white",
command=value_Gs)
btnGs.grid(row=0, column=6, padx=5, pady=5)
btnBb = Button(abc2, height=6, width=4, bd=4, text="Bb", font=("arial", 18, "bold"), bg="black", fg="white",
command=value_Bb)
btnBb.grid(row=0, column=8, padx=5, pady=5)
btnSpace5 = Button(abc2, state=DISABLED, height=6, width=2, bg="powder blue", relief=FLAT)
btnSpace5.grid(row=0, column=9, padx=0, pady=0)
btnCs1 = Button(abc2, height=6, width=4, bd=4, text="C#1",