I can not set an icon (.ico file)
root.iconbitmap("stuff/icon.ico")
I get the following error:
Traceback (most recent call last):
File "/home/kekx/Dokumente/VS/Shorty/shorty.py", line 213, in <module>
root.iconbitmap("stuff/icon.ico")
File "/usr/lib/python3.10/tkinter/__init__.py", line 2109, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "stuff/icon.ico" not defined
My folder structure looks like this:
.
-- shorty.py
-- stuff
-- icon.ico
-- ...
When I start the script via terminal the same error occurs (of course I changed into the directory of the script)
Does anyone know what this can be?
I have also already tried:
root.iconbitmap(os.path.dirname(os.path.abspath(__file__)) "/stuff/icon.ico")
CodePudding user response:
You have to use iconphoto
instead of iconbitmap
on Linux/macOS systems, to try:
icon = tk.PhotoImage(file='/path/to/img.png')
root.iconphoto(True, icon)