【问题标题】:GIO: get_icon() always returns NoneGIO:get_icon() 总是返回 None
【发布时间】:2011-09-14 06:35:35
【问题描述】:

根据GIO Documentation,可以通过g_file_info_get_icon()获取文件的Icon http://developer.gnome.org/gio/stable/GFileInfo.html#g-file-info-get-icon

但这不起作用,看看这个示例:

print(somefile) # <FileInfo object at 0x17bf820 (GFileInfo at 0x1b15d00)> 
icon = somefile.get_icon()
print(icon) # always None
if icon is Gio.Icon: 
    print("isicon") # never happens

我已经用我的整个主文件夹对其进行了测试,get_icon() 总是返回 None。我是否犯了任何错误,或者这个函数根本不能与 python / pygobject 一起使用?

【问题讨论】:

    标签: gtk python-3.x gio


    【解决方案1】:

    你有query_infostandard::icon 属性吗?例如,

    f = File.new_for_commandline_arg('...')
    info = f.query_info('standard::icon')
    print(info.get_icon())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-14
      • 2015-12-21
      • 2018-03-14
      • 1970-01-01
      相关资源
      最近更新 更多