I'm creating a tkinter app & when i added the app icon it shows this error
Traceback (most recent call last):
File "d:\Workspace\python demo\Workspace.py", line 553, in <module>
root.iconbitmap('icon.ico')
File "C:\Users\RAKESH\AppData\Local\Programs\Python\Python310\lib\tkinter\__init__.py", line 2109, in wm_iconbitmap return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "icon.ico" not defined
When first i created the app it's working fine but recently it's not working
root = Tk()
root.iconbitmap('icon.ico')
root.update()
starttime = time.time()
root.wm_title("Workspace")
ob = Login(root)
root.mainloop()
The solution provided by Thyrus works for me fine on Windows, but not on Linux. There I get the same error message as mentioned in the original question. According to https://www.delftstack.com/de/howto/python-tkinter/how-to-set-window-icon-in-tkinter I now use the following code which works for me on both systems:
import tkinter as tk
root = tk.Tk()
root.iconphoto(False, tk.PhotoImage(file='Capture.png'))
root.mainloop()
Therefore I had to convert my '.ico' to '.png' using ImageMagic:
convert Capture.ico Capture.png
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With