There can be multiple approaches to do what you want I would suggest you to add a Button
which when pressed will check the answer and goes to the next page so there'll be no extra score issues though I assume you probably have one page and which have multiple questions so these are some ideas which can be used to solve your issue.
I assigned a list which will store the correct answer in the function ajouter1()
and check if that answer is already in the list ( if ans not in score_list:
). Also passing an argument to the function by lambda: ajouter1("A1")
. Here's how you pass parameters to the function in tkinter.
Example:
...
score_list = []
def ajouter1( ans ):
global score
if ans not in score_list:
score+=1
Score = "Bravo, Votre score est de: " + str(score) + "/10"
var_label.set(Score)
score_list.append(ans)
Q1 = Label(root, text="1) Comment se nomme le président français?", font='Helvetica 10 bold')
Q1.pack()
Q1A = Radiobutton(root, text="Nicolas Sarkozy", value=2, variable=rep1)
Q1A.pack()
Q1B = Radiobutton(root, text="Emmanuel Macron", value=1, variable=rep1, command=lambda: ajouter1('A1'))
Q1B.pack()
Q1C = Radiobutton(root, text="François Hollande", value= 3, variable=rep1)
Q1C.pack()
...
Another approach that I can think of is when a user clicks on any of the Radiobutton
of a question then those Radiobutton
's state goes disabled so user won't cheat.
Something like this:

def ajouter1( ans ):
global score
if ans:
score+=1
Score = "Bravo, Votre score est de: " + str(score) + "/10"
var_label.set(Score)
Q1A['state'] = 'disabled'
Q1B['state'] = 'disabled'
Q1C['state'] = 'disabled'
Q1 = Label(root, text="1) Comment se nomme le président français?", font='Helvetica 10 bold')
Q1.pack()
Q1A = Radiobutton(root, text="Nicolas Sarkozy", value=2, variable=rep1, command=lambda: ajouter1(False))
Q1A.pack()
Q1B = Radiobutton(root, text="Emmanuel Macron", value=1, variable=rep1, command=lambda: ajouter1(True))
Q1B.pack()
Q1C = Radiobutton(root, text="François Hollande", value= 3, variable=rep1, command=lambda: ajouter1(False))
Q1C.pack()