本文整理汇总了Python中gtk.icon_theme_get_default方法的典型用法代码示例。如果您正苦于以下问题:Python gtk.icon_theme_get_default方法的具体用法?Python gtk.icon_theme_get_default怎么用?Python gtk.icon_theme_get_default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtk
的用法示例。
在下文中一共展示了gtk.icon_theme_get_default方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: iconFromName
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import icon_theme_get_default [as 别名]
def iconFromName(name,size="small"):
icon_theme = gtk.icon_theme_get_default()
icon_=icon_theme.lookup_icon(name, 48, 0)
is_in_theme=False
if icon_!=None:
sizes=icon_theme.get_icon_sizes(name)
if len(sizes)>0:
highest_res= sorted(icon_theme.get_icon_sizes(name))[::-1][0]
is_in_theme=True
icon=icon_theme.lookup_icon(name, highest_res, 0).get_filename()
else:
icon=icon_theme.lookup_icon(name, 48, 0).get_filename()
if is_in_theme==True:
return icon
elif os.path.isfile(name):
return name
else:
found=False
dir_list=IconTheme.icondirs
for d in dir_list:
if os.path.isdir(d):
for i in os.listdir(d)[::-1]:
if i.startswith(name):
path=os.path.join(d,i)
found=True
break
if found==True:
return path
else:
return icon_theme.lookup_icon("text-plain", 48, 0).get_filename()
示例2: ico_from_name
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import icon_theme_get_default [as 别名]
def ico_from_name(name,size="small"):
icon_theme = gtk.icon_theme_get_default()
icon_=icon_theme.lookup_icon(name, 48, 0)
is_in_theme=False
if icon_!=None:
sizes=icon_theme.get_icon_sizes(name)
if len(sizes)>0:
highest_res= sorted(icon_theme.get_icon_sizes(name))[::-1][0]
is_in_theme=True
icon=icon_theme.lookup_icon(name, highest_res, 0).get_filename()
else:
icon=icon_theme.lookup_icon(name, 48, 0).get_filename()
if is_in_theme==True:
return str(icon)
elif os.path.isfile(name):
return str(name)
else:
found=False
dir_list=IconTheme.icondirs
for d in dir_list:
if os.path.isdir(d):
for i in os.listdir(d)[::-1]:
if i.startswith(name):
path=os.path.join(d,i)
found=True
break
if found==True:
return str(path)
else:
return "/usr/share/duck-launcher/icons/apps.svg"
示例3: __init__
# 需要导入模块: import gtk [as 别名]
# 或者: from gtk import icon_theme_get_default [as 别名]
def __init__(self):
if self.INSTANCE is not None:
raise ValueError("An instantiation already exists!")
self.git = gtk.icon_theme_get_default()
if self.icon_exists('viber-normal') and self.icon_exists('viber-notification'):
self.icon_type = "SYSTEM"
self.icon_normal = "viber-normal"
self.icon_notification = "viber-notification"
else:
self.icon_type = "BUILTIN"
self.temp_icon_normal = tempfile.NamedTemporaryFile()
self.temp_icon_notif = tempfile.NamedTemporaryFile()
self.temp_icon_normal.write(self.ICON_NORMAL.decode('base64'))
self.temp_icon_notif.write(self.ICON_NOTIF.decode('base64'))
self.temp_icon_normal.flush()
self.temp_icon_notif.flush()
self.icon_normal = os.path.abspath(self.temp_icon_normal.name)
self.icon_notification = os.path.abspath(self.temp_icon_notif.name)
printf("Using %s icons\n", self.icon_type)