Something here is not working as the cards do not display the selected question and answer they just say "word" which is the placeholder. Does anyone have any idea what is going wrong? I think it may just be that something in the wrong order or place.
def next_card():
global current_card, flip_timer
window.after_cancel(flip_timer)
current_card = random.choice(selected_flashcards)
selected_question, selected_answer = selected_flashcard
selected_question = selected_question.strip("()").strip("'\"")
selected_answer = selected_answer.strip("()").strip("'\"")
canvas.itemconfig(card_title, text="Question", fill="black")
canvas.itemconfig(card_word, text=selected_question, fill="black")
canvas.itemconfig(card_background, image=card_front_img)
flip_timer = window.after(3000, func=flip_card)
def flip_card():
canvas.itemconfig(card_title, text = "Answer", fill = "white")
canvas.itemconfig(card_word, text=selected_answer, fill = "white")
canvas.itemconfig(card_background, image=card_back_img)
selected_flashcards.remove(current_card)
window = Toplevel()
window.title("Quick Revision")
window.config(padx=50, pady=50, bg=BACKGROUND_COLOR)
flip_timer = window.after(3000, func=flip_card)
canvas = Canvas(width=800, height=526)
card_front_img = PhotoImage(file="./images/card_front.png")
card_back_img = PhotoImage(file="./images/card_back.png")
card_background = canvas.create_image(400, 263, image=card_front_img)
card_title = canvas.create_text(400, 150, text="Title", font=("Ariel", 40, "italic"))
canvas.config(bg=BACKGROUND_COLOR, highlightthickness=0)
card_word = canvas.create_text(400, 263, text="Word", font=("Ariel", 60, "bold"), tags="word")
canvas.grid(row=0, column=0, columnspan=2)
check_image = PhotoImage(file="./images/right.png")
flip_button = Button(image=check_image, command=flip_card())
flip_button.grid(row=1, column=1, sticky="E")
next_card()
window.mainloop()
I tried placing the flipcard function within the nextcard function but this did not work.I did this because the first error it finds is that the selected answer is undefined in the flip card function.