Search code examples
pythonpygobject

PyGobject Application Icon


Possible Duplicate:
How to Add an icon to an ubuntu app

I am trying to create a base application code for the PyGObject app. I am not sure how to change the application icon.

I have this code.

from gi.repository import Gtk

win = Gtk.Window()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()

I have checked some of the sample codes and didn't found a way to do that. Any pointers?


Solution

  • For using a file relative to the script:

    win.set_icon_from_file("logo.png")
    

    For using a theme icon:

    win.set_icon_name("logo.png")
    

    PyGObject still doesn't have a decent API documentation (the last time I checked), for now you can use C API and old PyGtk documentation and "guess and try" what you need: http://developer.gnome.org/gtk3/3.0/ & http://developer.gnome.org/pygtk/stable/