Using Tkinter command “iconbitmap” to set window icon

前端 未结 3 1682
鱼传尺愫
鱼传尺愫 2020-12-21 16:25

I have a program with Tkinter window and I want to set an icon for the window. I coded this:okno.iconbitmap(os.path.dirname(os.path.abspath(__file__))+\"/icon.png\")

3条回答
  •  感动是毒
    2020-12-21 16:55

    Code to turn files into ico format with pillow library. Available formats: https://pillow.readthedocs.io/en/latest/handbook/image-file-formats.html

    from PIL import Image
    filen = r'icon.png'
    img = Image.open(filen)
    img.save('icon.ico',format = 'ICO', sizes=[(32,32)])
    

提交回复
热议问题