The two versions, 8.1 and 8.2, of the cricket scoreboard project have some key differences. Here’s a comparative overview:
Version 8.1
- Score Entry and Display: Score entry is more direct and handled by global variables, which are retrieved and updated based on user input.
- Player Name Handling: The conversion of player shirt numbers to names is done using simple conditional checks within the
scoreboard()function. - UI and Score Display: The window and labels are created within the
scoreboard()function. This setup means the UI is dynamically generated every time the function is called. - Player Swap Logic: The swapping of striker and non-striker is based on conditions within the
scoreboard()function, directly checking the last digit of overs or impact of the ball. - Data Persistence: The code writes new data to a CSV file after every update.
Version 8.2
- Data Management: It uses a slightly more modular approach with better-organized data management, leading to cleaner code and less reliance on global variables.
- Dynamic UI Updates: The second version incorporates dynamic updates within the existing UI, avoiding the need to recreate the entire window, which makes the program more efficient.
- Improved Player Handling: The player swap logic is refined and more robust, offering better control over the swapping mechanism.
- Enhanced Flexibility: This version seems to better handle various match scenarios by organizing the logic more effectively and offering a more streamlined UI experience.
Summary
- Version 8.1 focuses on simplicity with direct score entry and display, whereas Version 8.2 introduces a more polished structure with improved UI updates and better data management.
- Version 8.2 enhances user experience by offering a more responsive interface and more organized code, making it preferable for more complex and dynamic match scenarios.
from tkinter import *
window1=None
window2=None
window=None
label1=None
label2=None
label3=None
label4=None
label5=None
label6=None
label8=None
label9=None
label10=None
label11=None
label13=None
label14=None
def scoreboard():
global scoreshow
global strikervalue
striker=strikervalue.get()
global armvalue
arm=armvalue.get()
global strikerscorevalue
strikerscore=strikerscorevalue.get()
global nonstrikervalue
nonstriker=nonstrikervalue.get()
global nonstrikerscorevalue
nonstrikerscore=nonstrikerscorevalue.get()
global team1value
team1=team1value.get()
global overvalue
over=overvalue.get()
global bowlervalue
bowler=bowlervalue.get()
global bowlerstatsvalue
bowlerstats=bowlerstatsvalue.get()
global overstatsvalue
overstats=overstatsvalue.get()
global notevalue
note=notevalue.get()
global impactvalue
impact=impactvalue.get()
global team1scoreteam2value
team1scoreteam2=team1scoreteam2value.get()
#scoreshow+=impact
global team2value
team2=team2value.get()
global label1,label2,label3,label4,label5,label6,label8,label9,label10,label11,label13,label14
listinfo=[striker,strikerscore,nonstriker,nonstrikerscore,team1,
team1scoreteam2
,over,bowler,bowlerstats,
overstats,note,impact,team2,arm]
if striker=="45":
striker="ROHIT"
elif striker=="18":
striker="VIRAT"
if nonstriker=="45":
nonstriker="ROHIT"
elif nonstriker=="18":
nonstriker="VIRAT"
if bowler=="10":
bowler="SHAHEEN"
elif bowler=="71":
bowler="NASEEM"
n=read()
if n[13]!=arm:
import csv
fh=open("scoreinfo.csv","a")
fo=csv.writer(fh)
fo.writerow(listinfo)
fh.close()
global window1
global window2
new=read()
#print(new)
#print(new[11])
if new[11]=="1" or new[11]=="3" or new[11]=="0" and new[6][-1]=="6":
k=nonstrikervalue
p=nonstrikerscorevalue
nonstrikervalue=strikervalue
nonstrikerscorevalue=strikerscorevalue
strikervalue=k
strikerscorevalue=p
if window1 is not None:
label1.config(text=striker)
label2.config(text=strikerscore)
label3.config(text=nonstriker)
label4.config(text=nonstrikerscore)
label5.config(text=team1)
label6.config(text=team1scoreteam2)
label8.config(text=over)
label9.config(text="VS "+team2)
label10.config(text=bowler)
label11.config(text=bowlerstats)
label13.config(text=overstats)
label14.config(text=note)
else:
window1=Tk()
window1.geometry("1300x300")
window1.config(relief=RIDGE,background="#882626",bd=20,padx=180,pady=50)
label1=Label(window1,width=10,text=striker,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9,)
label1.place(x=0,y=80)
label2=Label(window1,width=5,text=strikerscore,font=("Arial",22),fg="blue",relief=RIDGE,bd=9,)
label2.place(x=200,y=80)
label3=Label(window1,width=10,text=nonstriker,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9)
label3.place(x=0,y=130)
label4=Label(window1,width=5,text=nonstrikerscore,font=("Arial",22),fg="blue",relief=RIDGE,bd=9,)
label4.place(x=200,y=130)
label5=Label(window1,width=5,text=team1,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9)
label5.place(x=335,y=80)
label6=Label(window1,width=7,text=team1scoreteam2,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9,)
label6.place(x=445,y=80)
label7=Label(window1,width=5,text="OVER",font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9)
label7.place(x=335,y=130)
label8=Label(window1,width=2,text=over,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9,)
label8.place(x=445,y=130)
label9=Label(window1,width=8,height=2,text="VS "+team2,font=("Arial",12),fg="blue",relief=RIDGE,bd=9,)
label9.place(x=500,y=130)
label10=Label(window1,width=10,text=bowler,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9)
label11=Label(window1,width=10,text=bowlerstats,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9,)
label12=Label(window1,width=10,text="THIS OVER",font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9)
label13=Label(window1,width=10,text=overstats,font=("Arial",22,"bold"),fg="blue",relief=RIDGE,bd=9,)
label10.place(x=620,y=80)
label11.place(x=821,y=80)
label12.place(x=620,y=130)
label13.place(x=821,y=130)
label14=Label(window1,width=35,height=1,text=note,font=("Arial"),fg="blue",relief=RIDGE,bd=9)
label14.place(x=0,y=35)
else:
print("UPDATE PRIMARY KEY......")
def read():
import csv
fh=open("scoreinfo.csv","r")
fo=csv.reader(fh)
fo=list(fo)
new=fo[-2]
return new
fh.close()
new=read()
strikervalue=new[0]
strikerscorevalue=new[1]
nonstrikervalue=new[2]
nonstrikerscorevalue=new[3]
team1value=new[4]
team1scoreteam2value=new[5]
overvalue=new[6]
bowlervalue=new[7]
bowlerstatsvalue=new[8]
overstatsvalue=new[9]
notevalue=new[10]
impactvalue=new[11]
team2value=new[12]
if new[11]=="1" or new[11]=="3" or new[11]=="0" and new[6][-1]=="6":
k=nonstrikervalue
p=nonstrikerscorevalue
nonstrikervalue=strikervalue
nonstrikerscorevalue=strikerscorevalue
strikervalue=k
strikerscorevalue=p
window=Tk()
window.geometry("1600x500")
window.title("scoreboard info entry")
window.config(background="skyblue",padx=30,pady=50,border=25)
labelstriker=Label(window,width=22,text="STRIKER SHIRT NO.:",font=("Arial",20),bg="black",fg="white",relief=RIDGE,bd=10)
labelstriker.place(x=0,y=10)
strikervalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
strikervalue.insert(0,new[0])
strikervalue.place(x=370,y=10)
labelstrikerscore=Label(window,width=22,text="STRIKER SCORE:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelstrikerscore.place(x=0,y=80)
strikerscorevalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
strikerscorevalue.insert(0,new[1])
strikerscorevalue.place(x=370,y=80)
labelnonstriker=Label(window,width=22,text="NON-STRIKER SHIRT NO.:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelnonstriker.place(x=0,y=160)
nonstrikervalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
nonstrikervalue.insert(0,new[2])
nonstrikervalue.place(x=370,y=160)
labelnonstrikerscore=Label(window,width=22,text="NON-STRIKER SCORE:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelnonstrikerscore.place(x=0,y=240)
nonstrikerscorevalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
nonstrikerscorevalue.insert(0,new[3])
nonstrikerscorevalue.place(x=370,y=240)
labelteam1=Label(window,width=22,text="BATTING TEAM NAME:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelteam1.place(x=0,y=320)
team1value=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
team1value.insert(0,new[4])
team1value.place(x=370,y=320)
labelteam2=Label(window,width=22,text="BOWLING TEAM NAME:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelteam2.place(x=0,y=400)
team2value=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
team2value.insert(0,new[12])
team2value.place(x=370,y=400)
labelimpact=Label(window,width=22,text="IMPACT OF BALL BOLWED:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelimpact.place(x=0,y=480)
impactvalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
impactvalue.insert(0,new[11])
impactvalue.place(x=370,y=480)
labelteam1score=Label(window,width=23,text="BATTING TEAM SCORE:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelteam1score.place(x=720,y=10)
team1scoreteam2value=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
team1scoreteam2value.insert(0,new[5])
team1scoreteam2value.place(x=1110,y=10)
labelover=Label(window,width=23,text="OVER :",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelover.place(x=720,y=80)
overvalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
overvalue.insert(0,new[6])
overvalue.place(x=1110,y=80)
labelbowler=Label(window,width=23,text="BOWLER SHIRT NO.:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelbowler.place(x=720,y=160)
bowlervalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
bowlervalue.insert(0,new[7])
bowlervalue.place(x=1110,y=160)
labelbowlerstats=Label(window,width=23,text="BOWLER STATS:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelbowlerstats.place(x=720,y=240)
bowlerstatsvalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
bowlerstatsvalue.insert(0,new[8])
bowlerstatsvalue.place(x=1110,y=240)
labeloverstats=Label(window,width=23,text="OVER STATS:",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labeloverstats.place(x=720,y=320)
overstatsvalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
overstatsvalue.insert(0,new[9])
overstatsvalue.place(x=1110,y=320)
labelnote=Label(window,width=23,text="NOTE::",font=("Arial",20),fg="white",bg="black",relief=RIDGE,bd=10)
labelnote.place(x=720,y=400)
notevalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
notevalue.insert(0,new[10])
notevalue.place(x=1110,y=400)
labelarm=Label(window,width=23,text="ARMVALUE::",font=("Arial",20,"bold"),fg="RED",bg="black",relief=RIDGE,bd=10)
labelarm.place(x=720,y=480)
armvalue=Entry(window,font=("Arial",20),fg="white",bg="red",bd=10,relief=RIDGE)
armvalue.insert(0,new[13])
armvalue.place(x=1110,y=480)
submit_button=Button(window,text="Submit",command=scoreboard,font=("Arial",30,"bold"),bd=20,relief=RIDGE)
submit_button.place(x=550,y=560)




Good Job dear..keep it up..
LikeLike