0% found this document useful (0 votes)
12 views36 pages

Compprorep

Uploaded by

justgaming160
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views36 pages

Compprorep

Uploaded by

justgaming160
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 36

DELHI PUBLIC SCHOOL, WHITEFIELD

Academic Year 2024-2025

Project Report
On Bank
Management
FOR AISSCE 2025 EXAMINATION
[AS A PART OF THE COMPUTER SCIENCE COURSE (083)]

Name Class Section Roll No


Aditya Sekhar 12 B
GSR Abhinav 12 B

Page 1 of 33
CERTIFICATE

This is to certify that the Project/ Dissertation


entitled Bank Management is a Bonafide work
done by Aditya Sekhar and GSR Abhinav of Class
XII Session 23-24 in partial fulfillment of CBSE's
AISSCE Examination 2025 and has been carried
out under my direct supervision and guidance.

………………………… ……………………………..
Signature of Principal Signature of Teacher

………………………… ……………………………..
Signature of Examiner Signature of Student

Page 2 of 33
ACKNOWLEDGEMENT

Apart from the efforts of the members of this team,


the success of any project depends largely on the
encouragement and guidelines of many others. We
take this opportunity to express our gratitude to the
people who have been instrumental in the
successful completion of this project.
We express a deep sense of gratitude to almighty
God for giving us strength for the successful
completion of the project.
We express our heartfelt gratitude to our parents
for their constant encouragement while carrying
out this project. We gratefully acknowledge the
contribution of the individuals who contributed to
bringing this project up to this level, who continue
to look after us despite our flaws.
Our sincere thanks to Ms. Pavithra NR, a guide
and a mentor, who critically reviewed our project
and helped in solving every problem, that
occurred during the implementation of the
project.

Page 3 of 33
Table of Contents

CERTIFICATE..........................................................2
ACKNOWLEDGEMENT..........................................3
INTRODUCTION...................................................5
OBJECTIVE AND PROJECT DEFINITION................6
HARDWARE AND SOFTWARE REQUIREMENTS..7
MODULES.............................................................8
Tkinter......................................................8
Pillow........................................................8
MYSQL Connector....................................9
Code and Output..................................................9
Database Description...............................9
Project code files.....................................10
Text files for question bank......................10
MainGame.py............................................11
NewUser.py...............................................13
LoginGame.py............................................16
Quizgame.py..............................................19
ShowScore.py.............................................27
deleteUser.py.............................................30
BIBLOGRAPHY........................................................33

Page 4 of 33
INTRODUCTION
BANK
MANAGEM
ENT:
Games are essential for development of the
students. It nurtures the competitive sprit in
students. This quiz game will enhance the
knowledge of the students on different subject.

Page 5 of 33
OBJECTIVE AND PROJECT
DEFINITION

In this project we have used many


programming features that we
learned throughout the year.
We have used File management as
Question bank for all the subjects.
We are using Database to store the user
Information to allow user to login and to save
their scores.
We have used TKinter to make the GUI of
the application.
We have used Pillow to show the image on
the screen.
We have used list extensively to load the
question bank and show random
questions.

Page 6 of 33
HARDWARE AND SOFTWARE
REQUIREMENTS
1. PC with Intel core i5 with 64 GB RAM and 64
bit OS
2. MS Windows 11 OS
3. Python 5.5
4. IDLE (Python 5.5)
5. Python Libraries
a. TKinter
b. Pillow
c. MySQL Connector
6. MySQL DB

Page 7 of 33
MODULES
Tkinter
Tkinter is a useful tool for creating a wide
variety of graphical user interfaces, including
windows, dialog boxes, and custom widgets. It
is particularly well-suited for building desktop
applications and adding a GUI to command-line
programs. It is indeed one of the fastest and
easiest ways to build GUI applications.
Moreover, Tkinter is cross-platform, hence the
same code works on macOS, Windows, and
Linux.
To install Tkinter: pip install Tk

Pillow
The Pillow library in Python contains all the
basic image processing functionality. We can
rotate, resize and transform an image. In this
code, the Pillow module has been used in
defining the backgrounds
that appear as the output.
To install Pillow: pip install pillow

Page 8 of 33
MYSQL Connector
MySQL Connector/Python enables Python
programs to access MySQL databases, using an
API that is compliant with the python.

Code and Output


Database Description:

Tables:

Page 9 of 33
Project code files:
S.no. File Name Description
1 MainGame.p Main window of the project gives user all the
y options provided by the
application
2 NewUser.py This window of the application allow user to add
new user
3 LoginGame.p This window allows user to login to play the quiz
y
4 Quizgame.py This is the window to show the questions and
receive the answers
5 ShowScore.p After the quiz it shows the score
y
6 deleteUser.p To delete a user from DB only Admin can delete
y the user

Text files for question bank


1. GK_ques.txt
2. GK_ans.txt
3. Comp_ques.txt
4. Comp_ans.txt
5. Math_ques.txt
6. Math_ans.txt
7. Sci_ques.txt
8. Sci_ans.txt
Image file for main window
Page 10 of 33
1. myimg.jpeg

Page 10 of 33
MainGame.py:
from randommport rand nt
from tknter mport
messagebox from tknter
mport *
mport tk nter as
tk mport os
from flIL mport ImageTk,
Image from Log nGame mport
*
from NewUser mport *
from deleteUser mport *

Ma n_w ndow = Tk()


Ma n_w ndow.ttle("Game")
sh ght = Ma n_w ndow.w nfo_screenhe
ght() sw dth = Ma n_w ndow.w
nfo_screenw dth()
Ma n_w ndow.geometry("%dx%d" %(swdth,sh ght))
Add ng background
bkImg = Image.open("my
mg.jpeg") mg =
ImageTk.flhotoImage(bkImg)

Canvas1=Canvas(Ma n_w ndow)


Canvas1.create_ mage(300,300, mage= mg)
Canvas1.confg (bg="Green",w dth=sw dth,he
ght=sh ght) Canvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(Ma n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.2,rely=0.1,relw dth=0.6,relhe ght=0.16)
head ngLabel = Label(head ngFrame1, text=" Welcome to \nWorld of Ǫu z",
bg='black', fg='wh te',font=('Century 15 bold'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

btn1 = Button(Ma n_w ndow,text="log n to fllay",bg='black',


fg='wh te', command=log n2game,font=('Century 15'))
btn1.place(relx=0.28,rely=0.4, relw dth=0.45,relhe ght=0.1)

btn2 = Button(Ma n_w ndow,text="New User",bg='black', fg='wh te',


command=newu,font=('Century 15'))
btn2.place(relx=0.28,rely=0.5, relw dth=0.45,relhe ght=0.1)

btn3 = Button(Ma n_w ndow,text="Delete User",bg='black', fg='wh


te', command=adm nl,font=('Century 15'))
btn3.place(relx=0.28,rely=0.6, relw dth=0.45,relhe ght=0.1)

btn4 = Button(Ma n_w ndow,text="Ǫu t",bg='black', fg='wh


te', command=Ma n_w ndow.destroy,font=('Century 15'))
btn4.place(relx=0.28,rely=0.7, relw dth=0.45,relhe
ght=0.1) Ma n_w ndow.ma nloop()

Page 11 of 33
Output:

Page 12 of 33
NewUser.py:
from random mport rand nt
from tk nter mport messagebox
from tk nter mport *
mport tk nter as tk
mport os
from flIL mport ImageTk, Image
mport mysql.connector
nu_pwd=None
nu_UName=None
nu_UID=None
def newu():
global Ma n_w ndow, Canvas1, nu_UName, nu_pwd,nu_UID
Ma n_w ndow = Tk()
Ma n_w ndow.t tle("Ǫu zGame New User")
Ma n_w ndow.m ns ze(w dth=400,he ght=400)
Ma n_w ndow.geometry("600x500")

Canvas1 = Canvas(Ma n_w ndow)


Canvas1.conf g(bg=" ff6e40")
Canvas1.conf g(bg=" ffce30")
Canvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(Ma n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.25,rely=0.1,relw dth=0.5,relhe ght=0.13)

head ngLabel = Label(head ngFrame1, text="Game New User", bg='black',


fg='wh te', font=('Century 15'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

labelFrame = Frame(Ma n_w ndow,bg='black')


labelFrame.place(relx=0.1,rely=0.4,relw dth=0.8,relhe ght=0.4)

lb1 = Label(labelFrame,text="UserID : ", bg='black', fg='wh te')


lb1.place(relx=0.05,rely=0.2, relhe ght=0.08)

nu_UID = Entry(labelFrame)
nu_UID.place(relx=0.3,rely=0.2, relw dth=0.62, relhe ght=0.08)

lb2 = Label(labelFrame,text="UserName : ", bg='black', fg='wh te')


lb2.place(relx=0.05,rely=0.35, relhe ght=0.08)

nu_UName = Entry(labelFrame)
nu_UName.place(relx=0.3,rely=0.35, relw dth=0.62, relhe ght=0.08)

Page 13 of 33
lb3 = Label(labelFrame,text="flassword : ", bg='black', fg='wh te')
lb3.place(relx=0.05,rely=0.5, relhe ght=0.08)

nu_pwd = Entry(labelFrame)
nu_pwd.place(relx=0.3,rely=0.5, relw dth=0.62, relhe ght=0.08)

Subm t Button
Subm tBtn = Button(Ma n_w ndow,text="Add User",bg=' d1ccc0',
fg='black',command=adduser)
Subm tBtn.place(relx=0.28,rely=0.9, relw dth=0.18,relhe ght=0.08)
qu tBtn = Button(Ma n_w ndow,text="Ǫu t",bg=' f7f1e3', fg='black',
command=Ma n_w ndow.destroy)
qu tBtn.place(relx=0.53,rely=0.9, relw dth=0.18,relhe ght=0.08)

Ma n_w ndow.ma nloop()


def adduser():
global nu_UName, nu_pwd,nu_UID,Ma n_w ndow
need to connect to db

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
suname = nu_UName.get()
spwd = nu_pwd.get()
su d = nu_UID.get()
values="('"+su d+"' ,'"+suname+"' ,'"+spwd+"')"
pr nt(values)
userTable = "gameplayer"
extractInfo="select * from {} where d='{}'".format(userTable,su d)
pr nt (extractInfo)
try:
cur.execute(extractInfo)
data =cur.fetchall()
Count=cur.rowcount
pr nt (data)
pr nt("rowCount=",Count)
f Count>0:
messagebox.show nfo("Error","User already ex st!")
Ma n_w ndow.destroy()
else:
extractInfo1=" nsert nto {} value {}".format(userTable,values)
cur.execute(extractInfo1)
con.comm t()
messagebox.show nfo("Success", "User Added successfully")
Ma n_w ndow.destroy()
Page 14 of 33
except:
messagebox.show nfo("Error", "Can't get the gameplayer data") Ma n_w ndow.destroy()

Output:

Page 15 of 33
LoginGame.py:
from random mport rand nt
from tk nter mport messagebox
from tk nter mport *
mport tk nter as tk
mport os
from flIL mport ImageTk, Image
mport mysql.connector
from Ǫu zgame mport *

txpwd=None
UName=None

def log n2game():


global Ma n_w ndow, Canvas1,txpwd,UName
Ma n_w ndow = Tk()
Ma n_w ndow.t tle("Ǫu zGame log n")
Ma n_w ndow.m ns ze(w dth=400,he ght=400)
Ma n_w ndow.geometry("600x500")
Add your own database name and password here to reflect n the code

con=mysql.connector.connect(host="localhost",user="root",password="Abc",dat
abase="db")
cur = con.cursor()
Enter Table Names here

Canvas1 = Canvas(Ma n_w ndow)


Canvas1.conf g(bg=" ff6e40")
Canvas1.conf g(bg=" 800080")
Canvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(Ma n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.25,rely=0.1,relw dth=0.5,relhe ght=0.13)

head ngLabel = Label(head ngFrame1, text="Game Log n", bg='black',


fg='wh te', font=('Century 15'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

labelFrame = Frame(Ma n_w ndow,bg='black')


labelFrame.place(relx=0.1,rely=0.4,relw dth=0.8,relhe ght=0.4)

lb1 = Label(labelFrame,text="Username : ", bg='black', fg='wh te')


lb1.place(relx=0.05,rely=0.2, relhe ght=0.08)

UName = Entry(labelFrame)

Page 16 of 33
UName.place(relx=0.3,rely=0.2, relw dth=0.62, relhe ght=0.08)

lb2 = Label(labelFrame,text="flassword : ", bg='black', fg='wh te')


lb2.place(relx=0.05,rely=0.35, relhe ght=0.08)

txpwd = Entry(labelFrame)
txpwd.place(relx=0.3,rely=0.35, relw dth=0.62, relhe ght=0.08)

Subm t Button
Subm tBtn = Button(Ma n_w ndow,text="SUBMIT",bg=' d1ccc0',
fg='black',command=glog n)
Subm tBtn.place(relx=0.28,rely=0.9, relw dth=0.18,relhe ght=0.08)
qu tBtn = Button(Ma n_w ndow,text="Ǫu t",bg=' f7f1e3', fg='black',
command=Ma n_w ndow.destroy)
qu tBtn.place(relx=0.53,rely=0.9, relw dth=0.18,relhe ght=0.08)

Ma n_w ndow.ma nloop()

def glog n():


global UName,txpwd,Canvas1,userTable,Ma n_w ndow con,cur,
suname = UName.get()
spwd = txpwd.get()
pr nt ("work n progress for log n u d=" ,suname ,"pwd=",spwd)
need to check DB f the username and flWD s correct.

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
userTable = "gameplayer"
extractInfo="select * from {} where d='{}'".format(userTable,suname)
try:
cur.execute(extractInfo)
data =cur.fetchall()
pr nt (data)
f data[0][0]==suname:
f data[0][2]==spwd:
Ma n_w ndow.destroy()
play(suname)

else:
messagebox.show nfo("Error", "Username or password not
val d")
Ma n_w ndow.destroy()
else:
messagebox.show nfo("Error", "Username or password not val d")
Ma n_w ndow.destroy()
Page 17 of 33
except:
messagebox.show nfo("Error", "Can't get the gameplayer data") Ma n_w ndow.destroy()

Output

Page 18 of 33
Quizgame.py:
from random mport rand nt
from tk nter mport messagebox
from tk nter mport *
mport tk nter as tk
mport os
from flIL mport ImageTk, Image
mport mysql.connector
from ShowScore mport *
quest onsGK=[]
AnswersGK=[]
quest onsMath=[]
AnswersMath=[]
quest onsS c=[]
AnswersS c=[]
quest onsComp=[]
AnswersComp=[]

qL st=[]
ansL st=[]
qvar1=None
quest on=""
f rst=0
count=0
score=0
Sk pcount=0
ans=""
my_label=None
qlableText=None
qlb1=None
head ngFrame1=None
head ngLabel=None
qlabelFrame=None
uname=""
subject=""
creat ng the tk nter w ndow

def mportans(f le,al st):


f le_name = os.path.jo n(os.getcwd(), f le)
pr nt (f le_name)
f le_ans = open(f le_name, 'r')
count = 0
l netype=0
l ne
Page 19 of 33
="a"

Page 110 of
33
wh le True:
count += 1
Get next l ne from f le
l ne = f le1.readl ne()
f l ne s empty
end of f le s reached
l ne = f le_ans.readl ne()
f not l ne:
break
pr nt(l ne);
al st=l ne.spl t(",")
pr nt(al st)
quest on_l st.append(l ne)
f le_ans.close()
pr nt(count)
return al st

def mportqu z(f le,quest on_l st):


"""
read the qu z f le and mport t n l st.
"""
f le = os.getcwd()+f le
f le = os.path.jo n(os.getcwd(), f le)
f le_name = os.path.jo n(os.getcwd(), f le)
pr nt (f le_name)
f le1 = open(f le_name, 'r')
count = 0
l netype=0
l ne
="a"
wh le True:
count += 1
Get next l ne from f le
l ne = f le1.readl ne()
f l ne s empty
end of f le s reached
l ne = f le1.readl ne()
f not l ne:
break
quest on_l st.append(l ne)
pr nt("L ne{}: {}".format(count, l ne.str p()))
f le1.close()
pr nt(count)
return quest on_l st

def showǪuest on():


Page 20 of 33
global ans, qL st, ansL st,count,qlableText,ansL st,qlb1,uname

Page 20 of 33
pr nt (" n showǪuest on")
f (count==5):
show result
text1="you score "+str(score)+ " outof 5"
messagebox.show nfo( "Result", text1)
addscoretoDB()
ex t(0)
else:
pr nt(" ns de else count=",count)
qno=rand nt(0,9-count)
pr nt(" ns de else qno=",qno)
count=count+1
q=qL st.pop(qno)
tokens=q.spl t("|")

qu=tokens[0]+"\n"+tokens[1]+"\n"+tokens[2]+"\n"+tokens[3]+"\n"+tokens[4]
qlableText.set(qu)
pr nt(ansL st)
ans=ansL st.pop(qno)

def addscoretoDB():
global uname,subject,score
pr nt ("user=",uname,"sub=" ,subject,"score=",score)

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
userTable = "scores"
values="('"+uname+"',"+score+",'"+subject+"')"
extractInfo1=" nsert nto {} value
('{}',{},'{}')".format(userTable,uname,score,subject)
cur.execute(extractInfo1)
con.comm t()
ShowScoreScreen(uname,subject)

def ver fyAns():


global ans,score,qvar1
messagebox.show nfo("ver fyAns",str(qvar1.get()))
f (ans==str(qvar1.get())):
score=score+1
pr nt(" ns de ver fyAns
ans=",ans,"Uans=",str(qvar1.get()),"score=",score)

def subm tCallBack():

Page 21 of 33
global
subject,f rst,qvar1,qL st,quest onsGK,quest onsMath,quest onsS c,quest onsCo
mp,AnswersGK,AnswersMath,AnswersS c,AnswersComp,ansL st
pr nt("qvar1.get()=",qvar1.get())
f(f rst==0):
messagebox.show nfo( "subm t", str(qvar1.get()))
f rst=1
f(str(qvar1.get())=="1"):
pr nt("GK")
subject="GK"
mportqu z('Ǫuest ons\GK_ques.txt',quest onsGK)
AnswersGK= mportans('Ǫuest ons\GK_ans.txt',AnswersGK)
pr nt(AnswersGK)
qL st=quest onsGK
ansL st=AnswersGK
el f(str(qvar1.get())=="2"):
pr nt("math")
subject="Math"
mportqu z('Ǫuest ons\Math_ques.txt',quest onsMath)
AnswersMath= mportans('Ǫuest ons\Math_ans.txt',AnswersMath)
qL st=quest onsMath
ansL st=AnswersMath
el f(str(qvar1.get())=="3"):
pr nt("sc ence")
subject="Sc ence"
mportqu z('Ǫuest ons\Sc _ques.txt',quest onsS c)
AnswersS c= mportans('Ǫuest ons\Sc _ans.txt',AnswersS c)
qL st=quest onsS c
ansL st=AnswersS c
el f(str(qvar1.get())=="4"):
pr nt("Comp sc ence")
subject="Computer"
mportqu z('Ǫuest ons\Comp_ques.txt',quest onsComp)
AnswersComp= mportans('Ǫuest ons\Comp_ans.txt',AnswersComp)
qL st=quest onsComp
ansL st=AnswersComp
showǪuest on()
else:
addscoretoDB()
qMa n_w ndow.destroy()

def nextCallBack():
global f rst, qL st, ansL st,var,qlableText

ver fyAns()
showǪuest on()
Page 22 of 33
def sk pCallBack():
global Sk pcount
f(Sk pcount==1):
messagebox.show nfo ("Sk p","You already sk ped 1 quest on, \ncannot
sk p th s one")
else:
Sk pcount=Sk pcount+1
showǪuest on()

def sel():
messagebox.show nfo("sel",var.get())
a=2

def play(user):
global qMa n_w ndow, qvar1,qlableText,qlb1,qlabelFrame,uname
qMa n_w ndow = Tk()
qMa n_w ndow.t tle("Ǫu z Game")
qMa n_w ndow.m ns ze(w dth=400,he ght=400)
qMa n_w ndow.geometry("600x500")
uname=user
qCanvas1 = Canvas(qMa n_w ndow)
qCanvas1.conf g(bg=" B22222")
qCanvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(qMa n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.25,rely=0.1,relw dth=0.5,relhe ght=0.13)
wel="Welcome "+uname
head ngLabel = Label(head ngFrame1, text=wel, bg='black', fg='wh te',
font=('Century 15'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

qlabelFrame = Frame(qMa n_w ndow,bg='black')


qlabelFrame.place(relx=0.1,rely=0.3,relw dth=0.8,relhe ght=0.6)

qlableText=tk.Str ngVar()
qlb1 = Label(qlabelFrame, textvar able=qlableText, bg='black',
fg='wh te',font=('Century 12'),just fy=LEFT,wraplength=450)
qlableText.set("Select The Ǫu z subject from below opt ons\n\nA) GK\nB)
Math\nC) Sc ence\nD) flython ")
qlb1.place(relx=0.05,rely=0.02, relw dth=0.9,relhe ght=0.5)

qvar1 = IntVar()
R1 = Rad obutton(qlabelFrame, text="A", var able=qvar1, value=1,
fg='black',bg='wh te',command=sel).place(relx=.1,rely=.55)
Page 23 of 33
R2 = Rad obutton(qlabelFrame, text="B", var able=qvar1, value=2,
fg='black',bg='wh te',command=sel).place(relx=.5,rely=.55)
R3 = Rad obutton(qlabelFrame, text="C", var able=qvar1, value=3,
fg='black',bg='wh te',command=sel).place(relx=.1,rely=.7)
R4 = Rad obutton(qlabelFrame, text="D", var able=qvar1, value=4,
fg='black',bg='wh te',command=sel).place(relx=.5,rely=.7)

Subm t Button
nxtBtn = Button(qMa n_w ndow,text="Next",bg=' d1ccc0',
fg='black',command=nextCallBack)
nxtBtn.place(relx=0.2,rely=0.9, relw dth=0.18,relhe ght=0.08)
Subm tBtn = Button(qMa n_w ndow,text="SUBMIT",bg=' d1ccc0',
fg='black',command=subm tCallBack)
Subm tBtn.place(relx=0.4,rely=0.9, relw dth=0.18,relhe ght=0.08)
qu tBtn = Button(qMa n_w ndow,text="Ǫu t",bg=' f7f1e3', fg='black',
command=qMa n_w ndow.destroy)
qu tBtn.place(relx=0.6,rely=0.9, relw dth=0.18,relhe ght=0.08)

qMa n_w ndow.ma nloop()

Page 24 of 33
Output:

Page 25 of 33
Page 26 of 33
ShowScore.py:
from random mport rand nt
from tk nter mport messagebox
from tk nter mport *
mport tk nter as tk
mport os
from flIL mport ImageTk, Image
mport mysql.connector
from Ǫu zgame mport *
uname=''
subject=''
def ShowScoreScreen(user,sub):
global Ma n_w ndow, Canvas1,uname,subject
Ma n_w ndow = Tk()
Ma n_w ndow.t tle("Ǫu zGame Score")
Ma n_w ndow.m ns ze(w dth=400,he ght=400)
Ma n_w ndow.geometry("600x500")
uname=user
subject=sub
Canvas1 = Canvas(Ma n_w ndow)
Canvas1.conf g(bg=" ff6e40")
Canvas1.conf g(bg=" FFFACD")
Canvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(Ma n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.25,rely=0.1,relw dth=0.5,relhe ght=0.13)

head ngLabel = Label(head ngFrame1, text="Score", bg='black',


fg='wh te', font=('Century 15'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

labelFrame=Frame( Ma n_w ndow,bg='black')


labelFrame.place(relx=0.1,rely=0.3,relw dth=0.8, relhe ght=0.5)

Label(labelFrame,text="%-20s%-10s%- 20s"%
('ID','Score','Subject'),bg='black',fg='wh te').place(relx=0.07,rely=0. 1)
Label(labelFrame,text="
-",bg='black',fg='wh te').place(relx=0.07,rely=0.2)

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
userTable = "scores"

Page 27 of 33
extractInfo="select * from {} where ID='{}' and
subject='{}'".format(userTable,uname,subject)
pr nt (extractInfo)
y=0.3
try:
cur.execute(extractInfo)
data =cur.fetchall()
messagebox ("Score",data)
pr nt(data)

for n data:
Label(labelFrame,text="%-20s%-10s%-
20s"%( [0], [1], [2]),bg='black',fg='wh te').place(relx=0.07,rely=y)
y=y+0.1
except:
messagebox.show nfo("Error", "Can't get the gameplayer data")
ex tBTN= Button(Ma n_w ndow,text="Ex t",bg=' f7f1e3', fg='black',
command=Ma n_w ndow.destroy)
ex tBTN.place(relx=0.4,rely=0.9,relw dth=0.18,relhe ght=0.18)
Ma n_w ndow.ma nloop()

Page 28 of 33
Output:

Page 29 of 33
deleteUser.py:
from random mport rand nt
from tk nter mport messagebox
from tk nter mport *
mport tk nter as tk
mport os
from flIL mport ImageTk, Image
mport mysql.connector
from Ǫu zgame mport *

tpwd=None
dUser = None

def adm nl():


global Ma n_w ndow, Canvas1,tpwd,dUser
Ma n_w ndow = Tk()
Ma n_w ndow.t tle("Delete User")
Ma n_w ndow.m ns ze(w dth=400,he ght=400)
Ma n_w ndow.geometry("600x500")

Canvas1 = Canvas(Ma n_w ndow)


Canvas1.conf g(bg=" ff6e40")
Canvas1.conf g(bg=" 288BA8")
Canvas1.pack(expand=True,f ll=BOTH)

head ngFrame1 = Frame(Ma n_w ndow,bg=" FFBB00",bd=5)


head ngFrame1.place(relx=0.25,rely=0.1,relw dth=0.5,relhe ght=0.13)

head ngLabel = Label(head ngFrame1, text="Delete User", bg='black',


fg='wh te', font=('Century 15'))
head ngLabel.place(relx=0,rely=0, relw dth=1, relhe ght=1)

labelFrame = Frame(Ma n_w ndow,bg='black')


labelFrame.place(relx=0.1,rely=0.4,relw dth=0.8,relhe ght=0.4)

lb1 = Label(labelFrame,text="Username : ", bg='black', fg='wh te')


lb1.place(relx=0.05,rely=0.2, relhe ght=0.08)

lb2 = Label(labelFrame,text="adm n", bg='black', fg='wh te')


lb2.place(relx=0.3,rely=0.2, relw dth=0.62, relhe ght=0.08)

lb1 = Label(labelFrame,text="Adm n flassword : ", bg='black', fg='wh te')


lb1.place(relx=0.05,rely=0.2, relhe ght=0.08)
tpwd = Entry(labelFrame)
tpwd.place(relx=0.3,rely=0.2, relw dth=0.62, relhe ght=0.08)

Page 30 of 33
lb2 = Label(labelFrame,text="Delete User : ", bg='black', fg='wh te')
lb2.place(relx=0.05,rely=0.35, relhe ght=0.08)

dUser = Entry(labelFrame)
dUser.place(relx=0.3,rely=0.35, relw dth=0.62, relhe ght=0.08)

Subm t Button
Subm tBtn = Button(Ma n_w ndow,text="SUBMIT",bg=' d1ccc0',
fg='black',command=alog n)
Subm tBtn.place(relx=0.28,rely=0.9, relw dth=0.18,relhe ght=0.08)
qu tBtn = Button(Ma n_w ndow,text="Ǫu t",bg=' f7f1e3', fg='black',
command=Ma n_w ndow.destroy)
qu tBtn.place(relx=0.53,rely=0.9, relw dth=0.18,relhe ght=0.08)

Ma n_w ndow.ma nloop()

def deleteUser(delU):

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
userTable = "scores"
extractInfo="delete from {} where d='{}'".format(userTable,delU)
extractInfo1="delete from {} where d='{}'".format ("gameplayer",delU)
pr nt(extractInfo)
try:
cur.execute(extractInfo)
cur.execute(extractInfo1)
con.comm t();
messagebox.show nfo("Success", "User Delete Successfully")
except:
messagebox.show nfo("Error", "Can't get the data from DB")
Ma n_w ndow.destroy()

def alog n():


global UName,tpwd,Canvas1,userTable,Ma n_w ndow,dUser con,cur,
suname = "adm n"
spwd = tpwd.get()
delU = dUser.get()
f (delU=='adm n'):
messagebox.show nfo("Error", "adm n Usercannot be deleted")
Ma n_w ndow.destroy()
else:
Page 31 of 33
pr nt ("work n progress for log n u d=" ,suname
,"pwd=",spwd) need to check DB f the username
and flWD s correct.

con=mysql.connector.connect(host="localhost",user="root",password="T aa123$"
,database="qu zgame")
cur = con.cursor()
userTable =
"gameplayer"
extractInfo="select * from {} where
d='{}'".format(userTable,suname)
pr
nt(extractInfo)
try:
cur.execute(extractInf
o) data =cur.fetchall()
pr nt (data)
f data[0][0]==suname:
f data[0]
[2]==spwd:
deleteUser(del
U)
Ma n_w
ndow.destroy()
play()
else:
messagebox.show nfo("Error", "You should be adm n to
delete user")
Ma n_w ndow.destroy()
else:
messagebox.show nfo("Error", "You should be adm n to delete

Page 32 of 33
Output:

BIBLOGRAPHY
1. https://www.mysql.com
2. https://pypi.org/project/Pillow/
3. https://docs.python.org/3/library/tkinter.html
4. https://www.w3schools.com/python/
5. Computer Science with Python (Textbook for Class XII) –
Sumita Arora

Page 33 of 33

You might also like