0

Possible Duplicate:
How can I change the folder icon?

I'm using python. I want change a file icon with Gio from a python app. I found a lot of deprecated documentation and I'm not sure how I can do it.

I tried this, but nothing happen:

from gi.repository import Gio
f = Gio.File.parse_name('/home/my_user/Desktop/test.txt')
f.set_attribute_string("metadata::custom_icon", '/usr/share/icons/Humanity/animations/48/brasero-disc-100.svg', Gio.FileQueryInfoFlags.NONE, None)

Which class and method have I use? Any idea, please? Thanks in advance!

Costales
  • 2,318

1 Answers1

3

This is mostly a duplicate of a previous question I answered, but you have 2 problems with your current code:

  • It is custom-icon and not custom_icon
  • You really do not want to set the icon of a file to be a file from the animations context of a theme. Or in general, a file at all. It's better to set the custom-icon-name attribute if you really must, and then have that icon be a part of the theme, so that it works correctly if the user changes themes.
dobey
  • 41,650