1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Tkinter image will not change

Discussão em 'Python' iniciado por Stack, Novembro 23, 2025.

  1. Stack

    Stack Membro Participativo

    import tkinter as tk
    from tkinter import ttk

    root = tk.Tk()

    def change():
    img2 = tk.PhotoImage(file = "img2.png")
    label.configure(image = img2)

    img1 = tk.PhotoImage(file = "img1.png")

    label = ttk.Label(root, image = img1)
    label.place(x = 0, y = 0)

    button = ttk.Button(root, text = "Change", command = change)
    button.place(x = 20, y = 20)


    This is my current code which has a button to change one image to another. The first image displays normally, however when the button is pressed tkinter just reverts to it's usual background. Please help this is driving me crazy

    Continue reading...

Compartilhe esta Página