I am using Tkinter to make a GUI application and am using the .iconbitmap() to specify my own .ico file instead of Tkinter's default. I am using Spyder.
import Tkinter as Tk
#program
root = tk.Tk()
root.iconbitmap(r'c:\Users\Kelin\Documents\Python Scripts\workspace\AGN\AGN.ico')
app = Application(master=root)
app.mainloop()
However, the first time I run the program, it throws this error:
TclError: bitmap "c:\Users\Kelin\Documents\Python Scripts\workspace\AGN\AGN.ico" not defined
From what I have read on this site (specifically, the question this was identified as a duplicate of), this can be caused when the .ico file is in the same directory as the .py file, and/or the full path isn't specified. However, as you can see the full path is specified and the icon is not in the same folder as the .py file. Furthermore, if I comment out the .iconbitmap() command, run the program, close it, uncomment the command and run it again, it works and uses my custom icon. If I restart the kernel, it throws the error again.
I assume it has something to do with something being loaded when I successfully run the program, can anyone explain this to me and offer a solution? Thanks.