0

I have this code, but why isn’t .ico file defined when setting window’s icon?

from tkinter import *
from PIL import ImageTk,Image

root = Tk()

root.title("Tkinter App")

root.iconbitmap('C:\Users\User\Desktop\Main\yazilimfoto\Ataturk1.jpg')

root.mainloop()
Eric Jin
  • 3,836
  • 4
  • 19
  • 45
  • Does this answer your question? [How to replace the icon in a Tkinter app?](https://stackoverflow.com/questions/33137829/how-to-replace-the-icon-in-a-tkinter-app) – Thingamabobs Aug 14 '22 at 16:10
  • *.jpg* isn't supported by tkinter. Refer to my answer in this thread. – Thingamabobs Aug 14 '22 at 16:11

1 Answers1

0

there are some problems in your code

the icon you are setting is in .jpg format. then use

ico = Image.open('test.jpg')
photo = ImageTk.PhotoImage(ico)
root.wm_iconphoto(False, photo)

and then

root.iconbitmap(photo)

and it will work. remember that you don't need to insert the entire file path (C:\Users\User\Desktop\Main\yazilimfoto\Ataturk1.jpg) but only the file path in your .py file directory

JacopoBiondi
  • 57
  • 1
  • 7