def set_icon(self, icon_name):
icon_name = uriparse(icon_name)
theme = Gtk.IconTheme.get_default()
# Make sure the icon name doesn't contain any special char
# Be sure that the icon still exists on the system
if (is_path(icon_name) and path.exists(icon_name)
and get_ext(icon_name) in SUPPORTED_EXTS):
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(icon_name,
Image.SIZE, Image.SIZE,
True)
elif theme.has_icon(icon_name):
pixbuf = theme.load_icon_for_scale(icon_name, Image.SIZE, 1, 0)
else:
pixbuf = theme.load_icon_for_scale("image-missing",
Image.SIZE, 1, 0)
self.set_from_pixbuf(pixbuf)
icons_utils.py 文件源码
python
阅读 30
收藏 0
点赞 0
评论 0
评论列表
文章目录