python图标的演变_来自SVG的Python Gtk3窗口图标/来自库存主题的...

我可能弄错了,这里有一些想法:

>我的机器上没有任何名为“applications-mail”的图标.我确实发现了许多“互联网邮件”图标.

/usr/share/icons/Mint-X/categories/96/applications-mail.svg

>另外,我相信svg图标应该在一个可伸缩的目录中.可能你发现的svg并没有被认出来.例如.我有:

/usr/share/icons/Tango/scalable/apps/internet-mail.svg

>我稍微修改了你的程序:

清单:

#!/usr/bin/env python3

from gi.repository import Gtk

class MainWindow(Gtk.Window):

def __init__(self):

super(MainWindow, self).__init__()

self.connect("delete-event", Gtk.main_quit)

#icon_name = "applications-mail"

icon_name = "internet-mail"

icon_theme = Gtk.IconTheme.get_default()

found_icons = set()

for res in range(0, 512, 2):

icon = icon_theme.lookup_icon(icon_name, res, 0)

#print(icon)

if icon != None:

found_icons.add(icon.get_filename())

if len(found_icons) > 0:

print("

".join(found_icons))

sizes = Gtk.IconTheme.get_default().get_icon_sizes(icon_name)

max_size = max(sizes)

print("max size = {} ({})".format(max_size, sizes))

pixbuf = icon_theme.load_icon(icon_name, max_size, 0)

self.set_default_icon_list([pixbuf])

self.show_all()

def run(self):

Gtk.main()

def main(args):

mainwdw = MainWindow()

mainwdw.run()

return 0

if __name__ == '__main__':

import sys

sys.exit(main(sys.argv))

我得到:

/usr/share/icons/Tango/24x24/apps/internet-mail.png

/usr/share/icons/Tango/scalable/apps/internet-mail.svg

/usr/share/icons/Tango/16x16/apps/internet-mail.png

/usr/share/icons/Tango/32x32/apps/internet-mail.png

/usr/share/icons/Tango/22x22/apps/internet-mail.png

max size = 32 ([22, 16, 24, 32, -1, 0])

其中-1表示可缩放图标. (所以,不要使用max() – 查找-1.

这来自developers’ site:

[gtk_icon_theme_get_icon_sizes] Returns an array of integers describing the sizes at which the icon is

available without scaling. A size of -1 means that the icon is

available in a scalable format.

编辑:更多想法:

> Gtk使用gdk-pixbuf.loaders模块来渲染图标等图像.您可能没有svg驱动程序正常工作.我似乎也记得librsvg库是必要的.

>即使另一个图标实际工作,您可能会看到图标缓存中的副本,并且您的图标渲染器可能仍然失败.

>图标缓存本身甚至可能存在问题.试试rebuilding the cache.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值