本文整理匯總了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)