I tried to do the same using the following code:
# A Python program to create root window with some options
from tkinter import *
# create top level window
root = Tk()
# set window title
root.title('Tkinter Demo')
# set window size
root.geometry('500x500')
# set window icon
root.wm_iconbitmap('PYTHON\Graphical User Interface[GUI]\pythonlogo.ico') # this line won't work for linux
# display window and wait for any events
root.mainloop()
and i also tried:
# A Python program to create root window with some options
from tkinter import *
# create top level window
root = Tk()
# set window title
root.title('Tkinter Demo')
# set window size
root.geometry('500x500')
# set window icon
img = PhotoImage(file='PYTHON/Graphical User Interface[GUI]/pythonlogo.xbm')
root.tk.call('wm', 'iconphoto', root._w, img)
# display window and wait for any events
root.mainloop()
The above code worked totally fine in Windows, but for linux i used the image file formats: .png,.jpeg,.gif,.ico,.xbm,.xpm but none of them worked.
I know the .png,.jpeg cannot be used. And, .gif,.ico formats only work on windows. I found from several forums that .xpm or .xbm formats worked fine. But, that was not true in my case.
I got the following error with .xpm as well as .xpm formats:
_tkinter.TclError: couldn't recognize data in image file "PYTHON/Graphical User Interface[GUI]/pythonlogo.xbm"
I've been struggling with this since quite a while. Any pointers or help towards the topic is well appreciated.
Thank You!