Creating or making my stop button in python function

Creating or making my stop button in python function
0
Questions = {"who was the first president of Nigeria":("Dr Nnamdi Azikuwe", "Name in full"),
                     "who drew the nigerian flag":("Taiwo Akinkunmi", "Name in full"),
                     "First Prime Minister Of Nigeria":("Tafawa Balewa", "Name in full"),
                     "The First Woman To Drive a Car In Nigeria":("Funmilayo Kuti", "Name and surname"),
                     "Who Brought Ebola To Nigeria":("Patrick Sawyer", "Name in full"),
                     "Who translated the english bible to the first yoruba bible":("Samuel Ajayi Crowther", "His full name"),
                     "In what year was the nigerian currency made":("1973", "The year alone"),
                     "The smallest state in Nigeria":("Lagos", ""),
                     "Who is the curent president of Nigeria":("Mohammed Buhari", "Just his name alone"),
                     "What was the first capital of Nigeria":("Calabar", ""),
                     "Who was the corageous queen who helped save her tribe in the history of the yoruba history":("Moremi", "Just her name"),
                     "Who helped stop the killing of twins in Nigeria":("Mary Slessor", "Name in full"),
                     "In what year did the chibock girls get kidnapped":("2014", "Year only"),
                     "How old is Nigeria":("59", "Age")}

from tkinter import *

import time

value = time.time()
root = Tk()

labeltext = StringVar()
timer = StringVar()
import random
Questions.keys()
list(Questions.keys())
random.choice(list(Questions.keys()))
List_of_questions = []
number_of_questions_for_the_game = 4
number_of_correct_answers = 0
#Label(text="Naija Questionaire?", font=("Algerian",20) ).pack()

#seperator = Frame(height=2, bd=1, bg=("blue"), borderwidth=0, highlightbackground=("purple"), relief=FLAT)
#seperator.pack(fill=X, padx=5, pady=5)

# choose a question at randomfrom the dictionary
# check if the question is in the list
# save to the list

while len(List_of_questions) < number_of_questions_for_the_game:
    choice = random.choice(list(Questions.keys()))
    if choice not in List_of_questions:
        List_of_questions.insert(0, choice)
        print(choice)

my_var = 0
number_of_tries = 1
guess_again = my_var
scoretext = StringVar()
stop_watch = Label(root, textvariable=timer, font=("Calibri",24), foreground="black", background="white")
timer.set("00:00")
stop_watch.place(x=800,y=150)
        
label = Label(root, textvariable=labeltext, font=("Calibri",24), foreground="black", background="white")
labeltext.set(List_of_questions[my_var])
label.place(x=50,y=50)

entrytext = StringVar()
entry = Entry(root, textvariable=entrytext, width=50)
entry.place(x=50,y=100)
import time

#background_image = Tk.PhotoImage(file = "nigeria flag.png")
#backgroung_frame = tk.frame(root, image = background_image)
#background_frame.place(relwidth=1, relheight=1) 

def play_again():
    global value
    global my_var
    global number_of_tries
    global number_of_correct_answers
    List_of_questions = []
    while len(List_of_questions) < number_of_questions_for_the_game:
        choice = random.choice(list(Questions.keys()))
        if choice not in List_of_questions:
            List_of_questions.insert(0, choice)
            print(choice)
           
    do_you_want_to_play_again_button.place_forget()
    win_label.place_forget()
    score_label.place_forget()
    my_var = 0
    number_of_tries = 1
    timer.set("00:00")
    value = time.time()
    labeltext.set(List_of_questions[my_var])
    entrytext.set("")
    number_of_correct_answers = 0

win_label = Label(root, text = "Congratulations you have completed the game", font=("Calibri",24), foreground="black", background="white")
score_label = Label(root, textvariable=scoretext, font =("Calibri",24), foreground="black", background="white")
do_you_want_to_play_again_button = Button(root, text="Play Again", command=play_again, background="red")


def update_timer():
    y = int(time.time() - value)
    minutes = int(y/60)
    seconds = y % 60
    #timer.set(str(minutes) + " : " + str(seconds))
    timer.set("%02i:%02i" %(minutes,seconds))
    stop_watch.after(1000, update_timer)
update_timer()             

def check_answer():
    global my_var
    global number_of_tries
    global number_of_correct_answers
    global do_you_want_to_play_again
    if Questions[labeltext.get()][0].lower() == entrytext.get().lower():
        number_of_correct_answers +=1
        if my_var == len(List_of_questions)-1:             
               win_label.place(x=50,y=145)
               do_you_want_to_play_again_button.place(x=150,y=120)  
               scoretext.set("Your score is" + str(number_of_correct_answers) + "/" + str(number_of_questions_for_the_game))
               score_label.place(x=50,y=600)              
               
        else:
            my_var += 1
            label = Label(root, text = " You\'ve " + str(len(List_of_questions) - my_var) + " questions " + " left ", font =("Calibri",24), foreground="black", background="white")
            label.place(x=150,y=200)
            number_of_tries = 1
            label.after(2000, label.place_forget)

               
        labeltext.set(List_of_questions[my_var])
                 
    elif number_of_tries > 0:
        number_of_tries -= 1
        label = Label(root, text = "Incorrect, you have 1 try left", font=("Calibri",24), foreground="black", background="white")
        label.place(x=50,y=145)       
       #time.sleep(1)
        label.after(3000, label.place_forget)
    else:
       if my_var == len(List_of_questions)-1:
          label = Label(root, text = "you have to answer this question, you have reached the end of the game", font=("Calibri",24), foreground="black", background="white")
          label.after(2000, label.place_forget)
          label.place(x=50,y=145)
          do_you_want_to_play_again_button.place(x=150,y=120)
          scoretext.set("Your score is" + str(number_of_correct_answers) + "/" + str(number_of_questions_for_the_game))
          score_label.place(x=50,y=145)    
              
       
       else:
           my_var += 1
           label = Label(root, text = " You\'ve " + str(len(List_of_questions) - my_var) + " questions " + " left ", font =("Calibri",24), foreground="black", background="white")
           label.place(x=150,y=200)
           label.after(2000, label.place_forget) 
           labeltext.set(List_of_questions[my_var])

           number_of_tries =1
        
    entrytext.set("")

def next_question():
    global my_var

    if my_var == len(List_of_questions)-1:
            labeltext.set(List_of_questions[my_var])
            label = Label(root, text = "You can\'t skip , you\'ve reached the end of the game", font=("Calibri",24), foreground="black", background="white")
            label.place(x=50,y=145)
            label.after(2000, label.place_forget)
                   
   
    else:
        List_of_questions.append(List_of_questions[my_var])
        my_var += 1
        label = Label(root, text = " You\'ve " + str(len(List_of_questions) - my_var) + " question\'s " + " left ", font =("Calibri",24), foreground="black", background="white")
        label.place(x=150,y=200)
        label.after(2000, label.place_forget)

        number_of_tries =1
    labeltext.set(List_of_questions[my_var])
    entrytext.set("")

def stop_button():
    global my_var

    if my_var == len(List_of_questions):

        

stop_button = Button(root,text="Stop", command=stop_button, background="red")
stop_button.place(x=150,y=120)        
submit_button = Button(root, text="Submit", command=check_answer, background="red")
submit_button.place(x=50,y=120)
skip_button = Button(root, text="Skip", command=next_question, background="red")
skip_button.place(x=100,y=120)

#guess_again_button = Button(root, text="Do You Want To Play Again?", command=check_answer, background="red")
#guess_again_button.place(x=50,y=145)