Feb-09-2021, 02:03 PM
(This post was last modified: Feb-09-2021, 02:03 PM by Rama02.
Edit Reason: Typo
)
Hello, I'm trying to design a GUI based code through Tkinter which include multiple choice questions that the user can click through radiobuttons. However when I try to run the code, I'm keep on getting a Syntax error starting that my positional arguments follow keyword argument.
This particular line seems to be where the error is orginating from.
This particular line seems to be where the error is orginating from.
Error: r1=Radiobutton(root,text=User_answers[indexes[0]][0],value=0,variable=i,font="Times New Roman",12,
bg="#E5E50E",fg="black",command=select)
I've proof checked my code numerous time & did search online however I did not obtain any results that are similar or close to the criteria that I am doing, hence I chose to come over here & enquire directly in hope of some guidance. If anyone can help me with the error and potentitally pin-point what I have done wrong, then I'd be very appreciative. Thanks 
import tkinter import random from tkinter import* root=tkinter.Tk() root.title("Anime Quiz") root.geometry("1000x800") root.config(background="#ffffff") import random #Questions=[ # "Q1: "In what location does Portgaz D. Ace die in One Piece?", # "Q2) "What is the nationality of Jonathan Joestar in JoJo?", # "Q3) "In what background was Yuno originally born in Black Clover?", # "Q4) "True Or False? Ray is Isabella’s son in The Promised Neverland", # "Q5) "What was the name of the academy that Izuku Modorya attended in BNHA?", # "Q6) "How many Dragon Balls are there in total?", # "Q7) "In total: How many emperors are featured in One Piece?", # "Q8) "Why did Sasuke go to Orochimaru?", # "Q9) "Why did Eren turn evil in AOT?", # "Q10) "How many souls do you need to eat to become a demon weapon in Soul Eater?", # ] #User_answers=[ # ["A)"Impel Down",B)"Dressrosa",C)"The Navy Headquarters",D)"Alabasta",], # ["A) "Japanese",B)"Italian",C)"Egyptian",D)"British",], # ["A) "Spade Kingdom",B)"Hage Village",C)"Golden Dawn Headquarters",)D)"Clover Kingdom",], # ["A) "True",B) "False") # ["A) "Kunugigaoka Junior High School",B)"U.A Highschool",C)"Kamome Academy",D)"Konoha Ninja Academy",], # ["A)"6",B)"8",C)"4",D)"7",], # ["A)"7",B)"2",C)"4",D)"32",], # ["A)"To team up with him",B)"To offer his body to Orochimaru",C)"To gain more power & murder his older brother, Itachi",D)"To revive the Uchiha clan"], # ["A)"To murder Eldians",B)"To gain freedom",C)"To avenge her mother's death",D)"To conqeour Marley",], # ["A)"100",B)"90",C)"50",D)"70",], # ] Answers=[2,3,0,0,1,3,2,2,1,0] User_answers=[] indexes = [] def gen(): global indexes while(len(indexes)<10): x = random.randint(0,14) if x in indexes: continue else: indexes.append(x) def showresult(score): lablQuestion.destroy() r1.destroy() r2.destroy() r3.destroy() r4.destroy() global label, label1, label11 label=Label(root,text="Your score is ",font=("Verdana",24),bg="#E5E50E",fg="black",justify="center") label.place(x=500,y=250) label1=Label(root,text=score,font=("Verdana", 24),bg="#E5E50E",fg="black",justify="center") label1.place(x=800,y=250) if score!=10: label11=Label(root,text="/10",font=("Verdana",24),bg="#E5E50E",fg="black",justify="center") label11.place(x=775,y=250) else: label11=Label(root,text="/10",font=("Verdana",24),bg="#E5E50E",fg="black",justify="center") label11.place(x=675,y=400) def calculate(): global indexes, User_answers, Answers x=0 score=0 for i in indexes: if User_answers[x]==answer[i]: score=score+1 x+=1 showresult(score) ques=1 def select(): global i,User_answers global lablQuestion,R1,R2,R3,R4,ques global ques x=i.get() User_answers.append(x) i.set(-1) if ques<10: lablQuestion.config(text=Questions[indexes[ques]]) r1['text']=User_answers[indexes[ques]][0] r2['text']=User_answers[indexes[ques]][1] r3['text']=User_answers[indexes[ques]][2] r4['text']=User_answers[indexes[ques]][3] ques+=1 else: calculate() def Question(): global lablQuestion,r1,r2,r3,r4,labelscore lablQuestion=Label(root,text=Questions[indexes[0]],font=("Agency FB",16),width=500,justify="center",wraplength=400,) lablQuestion.pack() img3=PhotoImage(file="C:/Users/Ramaz/OneDrive/Documents/Mustafa Quiz Code/103882 (1).png") labelimage3=Label(root,image=img3) labelimage3.pack(pady=5) global i,User_answers i=IntVar() i.set(-1) r1=Radiobutton(root,text=User_answers[indexes[0]][0],value=0,variable=i,font="Times New Roman",12, bg="#E5E50E",fg="black",command=select) r1.pack(pady=5) r2=Radiobutton(root,text=User_answers[indexes[0]][1],value=1,variable=i,font=("Times New Roman",12, bg="#E5E50E",fg="black",command=select) r2.pack(pady=5) r3=Radiobutton(root,text=User_answers[indexes[0]][2],value=2,variable=i,font=("Times New Roman",12) bg="#E5E50E",fg="black",command=select) r3.pack(pady=5) r4=Radiobutton(root,text=User_answers[indexes[0]][3],value=3,variable=i,font=("Times New Roman",12) bg="#E5E50E",fg="black",command=select) r4.pack(pady=5) def PressStart(): labelimage.destroy() labeltext.destroy() lablInstruction.destroy() lablRules.destroy() btnStart.destroy() gen() Question() img1=PhotoImage(file="C:/Users/Ramaz/OneDrive/Documents/Mustafa Quiz Code/b89597f8623c38e6e8b3f20afaad8522 (1).png") labelimage=Label(root,image=img1,background="#ffffff") labelimage.pack(pady=(40,0)) labeltext=Label(root,text="Anime Quiz",font=("Comic sans MS",24,"bold")) labeltext.pack(pady=(0,50)) img2=PhotoImage(file="C:/Users/Ramaz/OneDrive/Documents/Mustafa Quiz Code/Frame.png") btnStart=Button(root,image=img2,relief=FLAT,border=0,command=PressStart) btnStart.pack() lablInstruction=Label(root,text="Check Rules For Guidance And\nClick Start Once You Are ready",background="#ffffff",font=("Bembo",14),justify="center",) lablInstruction.pack() lablRules=Label(root,text="This quiz will consist of 6 questions relating to anime\nFor each question, you will only have 20 seconds to answer it\nOnce you have clicked a button, it will be your final choice\n Think wisely before selecting your answer",width=100,font=("Times New Roman", 14),background="#000000",foreground="#FF0000") lablRules.pack() root.mainloop()