[Python] I am not able to set the background image on top-level window [duplicate]

Discussão em 'Python' iniciado por Stack, Junho 10, 2025.

  1. Stack

    Stack Membro Participativo

    I have used many modules and also used global variable but its not appearing I don't know what's the issue

    def start_quizz(topic, quiz_type, level=1, coustmer=None):
    global bg_image_quiz_img
    def proceed_to_next_level():
    nonlocal level
    if quiz_type == "MCQs":
    if score >= 50:
    level += 1
    print(f"Proceeding to Level {level} for {coustmer}") # Debug statement
    if level <= 5:
    start_quizz(topic, quiz_type, level, coustmer)
    else:
    messagebox.showinfo("Quiz Completed", "You've completed all levels. Well done!")
    else:
    if score >= 30:
    level += 1
    print(f"Proceeding to Level {level} for {coustmer}") # Debug statement
    if level <= 5:
    start_quizz(topic, quiz_type, level, coustmer)
    else:
    messagebox.showinfo("Quiz Completed", "You've completed all levels. Well done!")

    questions = fetch_questions(topic, level, quiz_type) # Fetch questions based on quiz type
    if questions:
    print(f"Questions fetched for {quiz_type} - Level {level}: {questions}") # Debug statement
    quiz_window = tk.Toplevel()
    quiz_window.title(f"Quiz - {topic} ({quiz_type}, Level {level})")
    quiz_window.geometry("800x600")


    bg_image_quiz_img = tk.PhotoImage(file=r"C:\Users\lenovo\Pictures\quiz.png")
    bg_image_quiz = tk.Label(quiz_window, image=bg_image_quiz_img)
    bg_image_quiz.place(relheight=1, relwidth=1) # Set full-screen background


    enter image description here

    Continue reading...

Compartilhe esta Página