Why isn't .ico file defined when setting window's icon?

前端 未结 12 1564
一整个雨季
一整个雨季 2020-11-27 15:47

When I tried to change the window icon in the top left corner from the ugly red \"TK\" to my own favicon using the code below, Python threw an error:

from tk         


        
12条回答
  •  孤独总比滥情好
    2020-11-27 16:11

    from tkinter import *
    from PIL import ImageTk, Image
    
    Tk.call('wm', 'iconphoto', Tk._w, ImageTk.PhotoImage(Image.open('./resources/favicon.ico')))
    

    The above worked for me.

提交回复
热议问题