[Python] python tkinter image not appearing

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    import tkinter
    from tkinter import *
    from PIL import ImageTk, Image
    root=Tk()
    root.title("To-Do-List")
    root.geometry("400x600+400+100")
    root.resizable(width=False, height=False)
    task_list=[]
    image1=ImageTk.PhotoImage(Image.open("image/top.png"))
    root.iconbitmap("image/tick.png")
    imagelabel=Label(root,image=image1)
    infolabel=Label(root, text="To-Do-List",font="Helvetica 12 bold")

    imagelabel.pack()
    infolabel.pack()

    root.mainloop()


    this window appears when i press run, it should have an icon on top and the picture according to the code, but none of these appear to be here

    The image files are addressed correctly, but I am getting a blank screen. What can I do?

    I checked if PIL was installed, and yes, it was. I am expecting the picture to appear. I also checked if the pictures are there using the os module, and it showed true.

    Continue reading...

Compartilhe esta Página