I know this might be obvious, but in tkinter you can set an icon, but I have found it really hard to find one. I just wanted to know if you have to use the .ico
format for the file or if there is a way to use .png
or .jpeg
files.
Currently I have
window = Tkinter.Tk()
window.title("Weclome!")
window.geometry("200x300")
window.wm_iconbitmap("Icon.ico")
window.configure(background = "Black")
That is the whole setup I have and I just want to know about line 4:
window.wm_iconbitmap("Icon.ico")
Thanks for responding to my question, although i am sorry for not spending more time looking into the question rather than just asking here.
Let's start by reading the documentation!
The documentation at effbot.org says the following regarding
iconbitmap(bitmap=None)
So here's the documentation about
iconwindow(window=None)
:According to this other documentation, which actually says the same things as the docstrings of the homonymous method for
tkinter
in (at least) Python 2.7, 3.5 and 3.6:So here's the original Tk documentation:
From my understanding of
Tcl
, herewindow
is your toplevel window (either an instance ofTk
orToplevel
).Not very concrete and thus helpful answer so far.
My conclusion
The
iconbitmap
function (or method, depending on the programming language) should be used to set a bitmap image to the window when the window is iconified.On Windows you're allowed to set a full path specification to any file which contains a valid Windows icon is also accepted (usually
.ico
or.icr
files), or any file for which the shell has assigned an icon.So which images are bitmaps?
xbm
andxpm
(for X Window System)According to the Wikipedia article to which I linked "bitmap" to above:
BMP file format
Netpbm format
.wbmp
ILBM
...
So most of the bitmap file formats are not cross-platform! In other words, if someone tells you to use a
xbm
image for the icon, it may not work on your platform becausexbm
are bitmaps for X Window System.Note: even after this answer you may still have problems!
Other possible useful articles