from tkinter import *
from tkinter.colorchooser import *
from tkinter.messagebox import *
from tkinter.constants import *
#g= tkinter.Tk()
g=Tk()
#g.config(background="white")
n=StringVar()
q=1
questions={" 1.which this program? :":"C. py",
" 2.why you use py? :":"D. both AB",
" 3.when you will be a programer?:":"D. fastly ",
#" 4.why you choice py?: ":"A"
}
options=[["A. java","B. c++","C. py","D. code"],
["A. easy","B. global","C. non","D. both AB"],
["A. after year","B.after six month","C. noon","D. fastly "],
#["A. easy","B. global","C. someone recommend","D. yes "]
]
def cin():
global q
if q < len(questions):
ff=Label(g,text=questions[q])
ff.pack()
k =(questions.get(questions[q]))
for i in options[q-1]:
c = Radiobutton(g, text = i,fg = "black", width = 12, height = 1,variable=n, value=i ,bd = 2, bg = "white", cursor = "hand2" ,command=lambda:cin())
c.pack()
s = n.get()
if s == k :
showinfo(title='information',message='hi.. u passed')
q += 1
else:
showerror(title='error',message='hi.. u missed something')
else:
showinfo(title='information',message='hi.. u finished')
cin()
g.mainloop()
يظهر لي الخطأ التالي:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 41, in <module>
cin()
File "/data/user/0/ru.iiec.pydroid3/files/temp_iiec_codefile.py", line 25, in cin
ff=Label(g,text=questions[q])
KeyError: 1
بينما انا اللي اريده يطلع لي السؤال الاول مع خيارته واجيب عليه واذا كانت الاجابه صح يطلع لي السؤال الثاني.. وهكذا