using python 3.9.1 and tkinter from fedora cinnamon repos, trying to set window's icon with tkinter running this code:
import tkinter as tk
class App(tk.Tk):
def __init__(self):
super().__init__()
self.title("My Tkinter app")
self.iconbitmap("python.ico")
self.geometry("400x200+10+10")
if __name__ == "__main__":
app = App()
app.mainloop()
the ico image used is this: python.ico, but get this message when run the code:
self.iconbitmap("python.ico")
File "/usr/lib64/python3.9/tkinter/__init__.py", line 2072, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "python.ico" not defined
already tried to use wm_iconbitmap instead iconbitmap buth don't work, How could change window icon?
The solution in the post sugested is put an r letter before the "" in the iconbitmap method, I tried but don't work for my case.
At first convert python.ico to python.xbm (for example using GIMP). Then prepend the filename with "@". For example:
I have checked this code in UbuntuMate and SuSE Linux, python3.6