python-3.xiconstkinterlauncher

tkinter TclError: error reading bitmap file


I am trying to set an application icon (python3 / tkinter) like this:

Interface()
root.title("Quicklist Editor")
root.iconbitmap('@/home/jacob/.icons/qle_icon.ico')
root.resizable(0, 0)
root.mainloop()

no matter what I do, I keep getting an error message (Idle), saying:

return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: error reading bitmap file "/home/jacob/.icons/qle_icon.ico"

What am I doing wrong?


Solution

  • The problem is not the code, but the icon. I tried creating an xbm with another program than Gimp (some KDE icon editor), and although it looks terrifyingly ugly, it does show an icon. I guess I have to find a creator that gives an "understandable" icon for my Python program.


    Edit

    The iconbitmap method turned out to be black and white only, so it was useless after all.

    After a long search, I found the solution to set the color of an application's icon for Python 3 (on Linux). I found it here:

    root = Tk()
    img = PhotoImage(file='your-icon')
    root.tk.call('wm', 'iconphoto', root._w, img)