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

前端 未结 12 1573
一整个雨季
一整个雨季 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条回答
  •  猫巷女王i
    2020-11-27 16:07

    Both codes are working fine with me on python 3.7..... hope will work for u as well

    import tkinter as tk
    m=tk.Tk()
    m.iconbitmap("myfavicon.ico")
    m.title("SALAH Tutorials")
    m.mainloop()
    

    and do not forget to keep "myfavicon.ico" in the same folder where your project script file is present

    Another method

    from tkinter import *
    m=Tk()
    m.iconbitmap("myfavicon.ico")
    m.title("SALAH Tutorials")
    m.mainloop()
    

    [*NOTE:- python version-3 works with tkinter and below version-3 i.e version-2 works with Tkinter]

提交回复
热议问题