本文整理匯總了Python中theme.Theme.has_surface方法的典型用法代碼示例。如果您正苦於以下問題:Python Theme.has_surface方法的具體用法?Python Theme.has_surface怎麽用?Python Theme.has_surface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類theme.Theme
的用法示例。
在下文中一共展示了Theme.has_surface方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: IconFactory
# 需要導入模塊: from theme import Theme [as 別名]
# 或者: from theme.Theme import has_surface [as 別名]
#.........這裏部分代碼省略.........
if os.path.isfile(path):
icon = self.__icon_from_file_name(path, icon_size)
if icon:
return icon
return None
#### Other commands
def __command_clear(self, surface):
if self.dockbar_r().orient in ("left", "right"):
w = self.size
h = int(self.size * self.ar)
else:
w = int(self.size * self.ar)
h = self.size
new = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
ctx = cairo.Context(new)
ctx.set_source_rgba(0, 0, 0)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.paint_with_alpha(0)
return new
def __command_get_pixmap(self, surface, name):
if surface is None:
if self.dockbar_r().orient in ("left", "right"):
width = self.size
height = int(self.size * self.ar)
else:
width = int(self.size * self.ar)
height = self.size
else:
width = surface.get_width()
height = surface.get_height()
if self.theme.has_surface(name):
surface = self.__resize_surface(self.theme.get_surface(name),
width, height)
else:
logger.warning("theme error: pixmap %s not found" % name)
return surface
def __command_fill(self, surface, color, opacity="100"):
w = surface.get_width()
h = surface.get_height()
new = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
ctx = cairo.Context(new)
ctx.set_source_surface(surface)
ctx.paint()
alpha = self.__get_alpha(opacity)
c = self.__get_color(color)
r = float(int(c[1:3], 16))/255
g = float(int(c[3:5], 16))/255
b = float(int(c[5:7], 16))/255
ctx.set_source_rgba(r, g, b)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.paint_with_alpha(alpha)
return new
def __command_combine(self, surface, pix1, pix2, degrees=None):
# Combines left half of surface with right half of surface2.
# The transition between the two halves are soft.
# Degrees keyword are kept of compability reasons.
w = surface.get_width()
h = surface.get_height()
示例2: IconFactory
# 需要導入模塊: from theme import Theme [as 別名]
# 或者: from theme.Theme import has_surface [as 別名]
#.........這裏部分代碼省略.........
data_folders = None
if os.environ.has_key("XDG_DATA_DIRS"):
data_folders = os.environ["XDG_DATA_DIRS"]
if not data_folders:
data_folders = "/usr/local/share/:/usr/share/"
for data_folder in data_folders.split(':'):
#The line below line used datafolders instead of datafolder.
#I changed it because I suspect it was a bug.
paths = (os.path.join(data_folder, "pixmaps", icon_name),
os.path.join(data_folder, "icons", icon_name))
for path in paths:
if os.path.isfile(path):
icon = self.icon_from_file_name(path, icon_size)
if icon:
return icon
return None
#### Other commands
def command_get_pixmap(self, surface, name, size=0):
if surface is None:
if self.globals.orient == 'h':
width = int(self.size * ar)
height = self.size
else:
width = self.size
height = int(self.size * ar)
else:
width = surface.get_width()
height = surface.get_height()
if self.theme.has_surface(name):
surface = self.resize_surface(self.theme.get_surface(name),
width, height)
else:
print "theme error: pixmap %s not found"%name
return surface
def command_fill(self, surface, color, opacity=100):
w = surface.get_width()
h = surface.get_height()
new = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
ctx = cairo.Context(new)
ctx.set_source_surface(surface)
ctx.paint()
alpha = self.get_alpha(opacity)
c = self.get_color(color)
r = float(int(c[1:3], 16))/255
g = float(int(c[3:5], 16))/255
b = float(int(c[5:7], 16))/255
ctx.set_source_rgba(r, g, b)
ctx.set_operator(cairo.OPERATOR_SOURCE)
ctx.paint_with_alpha(alpha)
return new
def command_combine(self, surface, pix1, pix2, degrees=90):
# Combines left half of surface with right half of surface2.
# The transition between the two halves are soft.
w = surface.get_width()
h = surface.get_height()
if pix1=="self":
p1 = surface