0

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.

Kelin KO
  • 1
  • 2
  • possible duplicate of [Set window icon](http://stackoverflow.com/questions/18537918/set-window-icon) – BartoszKP Jul 20 '15 at 20:44
  • You've misread the linked duplicate. The reason indicated in the accepted answer states that the problem occurs *when the icon is in the same directory*, not when it's not. – BartoszKP Jul 20 '15 at 21:34
  • Oh I see, thank you. – Kelin KO Jul 20 '15 at 22:57
  • I moved the .ico file to a completely different directory, and double checked that the paths are correct, and it is still giving the same error :/ – Kelin KO Jul 20 '15 at 23:14
  • Sorry, no idea then. Please consider updating the question (without the "edit" marks - just rewrite the relevant part) - hopefully someone else will have the solution. Good luck! – BartoszKP Jul 20 '15 at 23:24

0 Answers0