python - Set window icon -


when tried change window icon in top left corner ugly red "tk" own favicon using code below, python threw error:

from tkinter import * root = tk()  #some buttons, widgets, lot of stuff  root.iconbitmap('favicon.ico') 

this should set icon 'favicon.ico' (according lot of forum posts on web). unfortunately, line throw following error:

traceback (most recent call last):   file "d:\ladvclient\mainapp.py", line 85, in <module>     root.iconbitmap(bitmap='favicon.ico')   file "c:\python33\lib\tkinter\__init__.py", line 1637, in wm_iconbitmap     return self.tk.call('wm', 'iconbitmap', self._w, bitmap) _tkinter.tclerror: bitmap "favicon.ico" not defined 

what did:

  • i checked path - 100% correct
  • i tried other file formats .png or .bmp - none worked
  • i looked problem on many websites

and third point, effbot.org, favorite site tkinter, told me windows ignores iconbitmap function. doesn't explain why throws error!

there "hackish" ways avoid issue, none of them written python 3.x.

so final question is: there way custom icon using python 3.x , tkinter?

also, don't tell me should use gui library. want program work on every platform. want coded version, not py2exe or sth solution.

you must not have favicon.ico in same folder script or, namely, on path. put in full pathname. example, works:

from tkinter import * root = tk()  root.iconbitmap(r'c:\python32\dlls\py.ico') root.mainloop() 

but blows same error:

from tkinter import * root = tk()  root.iconbitmap('py.ico') root.mainloop() 

Comments

Post a Comment

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -

android - send complex objects as post php java -