I want to get the default icon for a corresponding file using gtk.
I tried this method in python3 but it gave me an error
from gi.repository import Gio as gio
from gi.repository import Gtk
import os
def get_icon_filename(filename,size):
#final_filename = "default_icon.png"
final_filename = ""
if os.path.isfile(filename):
# Get the icon name
file = gio.File(filename)
file_info = file.query_info('standard::icon')
file_icon = file_info.get_icon().get_names()[0]
# Get the icon file path
icon_theme = gtk.icon_theme_get_default()
icon_filename = icon_theme.lookup_icon(file_icon, size, 0)
if icon_filename != None:
final_filename = icon_filename.get_filename()
return final_filename
print(get_icon_filename("/home/newtron/Desktop/Gkite_Logo.png",64))
Err
File "geticon", line 11, in get_icon_filename
file = gio.File(filename)
TypeError: GInterface.__init__() takes exactly 0 arguments (1 given)
I don't have any previous experience in gio module. Does my code have any problem? If it has not what is the solution to this error.