python 2.7 - Why do I always have to rewrite .iconbitmap() command in order for it to work? -


i using tkinter make gui application , using .iconbitmap() specify own .ico file instead of tkinter's default. using spyder.

import tkinter 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, first time run program, throws error:

tclerror: bitmap "c:\users\kelin\documents\python scripts\workspace\agn\agn.ico" not defined 

from have read on site (specifically, question identified duplicate of), can caused when .ico file in same directory .py file, and/or full path isn't specified. however, can see full path specified , icon not in same folder .py file. furthermore, if comment out .iconbitmap() command, run program, close it, uncomment command , run again, works , uses custom icon. if restart kernel, throws error again.

i assume has something being loaded when run program, can explain me , offer solution? thanks.


Comments