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

前端 未结 12 1544
一整个雨季
一整个雨季 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:20

    No way what is suggested here works - the error "bitmap xxx not defined" is ever present. And yes, I set the correct path to it.

    What it did work is this:

    imgicon = PhotoImage(file=os.path.join(sp,'myicon.gif'))
    root.tk.call('wm', 'iconphoto', root._w, imgicon)  
    

    where sp is the script path, and root the Tk root window.

    It's hard to understand how it does work (I shamelessly copied it from fedoraforums) but it works

提交回复
热议问题