Setting Application icon in my python Tk base application (On Ubuntu) Setting Application icon in my python Tk base application (On Ubuntu) tkinter tkinter

Setting Application icon in my python Tk base application (On Ubuntu)


You want to use wm iconphoto. Being more used to Tcl/Tk than Python Tkinter I don't know how that is exposed to you (maybe root.iconphoto) but it takes a tkimage. In Tcl/Tk:

image create photo applicationIcon -file application_icon.pngwm iconphoto . -default applicationIcon

In Tk 8.6 you can provide PNG files. Before that you have to use the TkImg extension for PNG support or use a GIF. The Python PIL package can convert images into TkImage objects for you though so that should help.

EDIT

I tried this out in Python as well and the following worked for me:

import Tkinterfrom Tkinter import Tkroot = Tk()img = Tkinter.Image("photo", file="appicon.gif")root.tk.call('wm','iconphoto',root._w,img)

Doing this interactively on Ubuntu resulted in the application icon (the image at the top left of the frame and shown in the taskbar) being changed to use my provided gif image.


This worked for me

from tkinter import *       raiz=Tk()raiz.title("Estes es el titulo")img = Image("photo", file="pycharm.png")raiz.tk.call('wm','iconphoto',raiz._w, img)raiz.mainloop()


Try this:

root.iconbitmap('@window.xbm')

And quote:

Set (get) the icon bitmap to use when this window is iconified. This method are ignored by some window managers (including Windows).

Note that this method can only be used to display monochrome icons. To display a color icon, put it in a Label widget and display it using the iconwindow method instead.