I know this is very simple, just use the command self.set_icon_from_file("icon.png"), however my program still does not display the icon. I made sure the icon.png is in the same working directory as the Python file. I also tried giving the complete file path, but still it does not display the icon.
I am using Ubuntu 10.10 if that helps and using Python V2.6. I use Glade Interface Designer to design the GUI. However, I tried setting the icon both using Glade and using the command above.
I hope I have provided sufficient information.
EDIT: I got the status icon to work in my program.. However in the question I meant the program icon displayed in the task bar and also on the left side of the application bar.
This may be your problem — paths are looked up relative to the working directory of the Python interpreter, not the file containing the code. I often find myself defining a function like:
Mine isn’t actually quite that verbose, but hopefully the variable names make it clear what’s going on. Also, getting the absolute path isn’t strictly necessary, but might help if you need to debug.
Then you can just do:
Update: Here is a demo program. “icon.png” is in the same directory as this script, and I run it using
./gtktest.py. I see the icon in the top left corner (standard place for my theme).icon.pngis just a shape drawn in Inkscape and exported as a bitmap (it works with the original SVG too, anyway).