GNOME Builder - Python - How to set application icon?

I’m creating a GTK application using GNOME Builder in Python and I wanted to add an icon for my application.
I’ve found:

  1. Gtk.Window.set_icon(GdkPixbuf.Pixbuf.new_from_resource("/img/icon.png")) but the icon looks pixelated.
  2. Add the Icon path in the .desktop file but I don’t know where to add my icon so the desktop file can be able to recognize it.

See the " Application icons" section in Themed Icons

The icon theme specification defines a universal fallback theme, called hicolor, in which applications can install icons that need to be known by the rest of the system.

The main example for this is the application icon that is used in the applications desktop file. This icon should be named to match the application name, and be installed in /usr/share/icons/hicolor/48x48/apps/. Other sizes are optional, but a 256×256 icon is the default size used by GNOME in its application grid, so you’re strongly encouraged to provide one.

Applications are also encouraged to install a symbolic version of the application icon into the hicolor theme, with the same name and a -symbolic suffix. The symbolic icon will be used in the HighContrast theme. Symbolic icons can be installed as SVG, in the /usr/share/icons/hicolor/symbolic/apps directory (which was added to hicolor in 0.15), or as .symbolic.png files in /usr/share/icons/hicolor/48x48/apps/. Other sizes are optional.

After installing your app icons (and .desktop file) with the correct application ID (the one you set when constructing Gtk.Application), the icon will be picked up by the desktop environment.

Some desktop environments still look for icons set on windows. So you probably need to use Gtk.Window.set_icon_name as well. Don’t use Gtk.Window.set_icon, though, which seems to have been removed in GTK 4.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.