当前位置: 首页>>代码示例>>Python>>正文


Python Theme.get_surface方法代码示例

本文整理汇总了Python中theme.Theme.get_surface方法的典型用法代码示例。如果您正苦于以下问题:Python Theme.get_surface方法的具体用法?Python Theme.get_surface怎么用?Python Theme.get_surface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在theme.Theme的用法示例。


在下文中一共展示了Theme.get_surface方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: IconFactory

# 需要导入模块: from theme import Theme [as 别名]
# 或者: from theme.Theme import get_surface [as 别名]

#.........这里部分代码省略.........
                    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()
        if pix1=="self":
开发者ID:M7S,项目名称:dockbarx,代码行数:70,代码来源:iconfactory.py

示例2: IconFactory

# 需要导入模块: from theme import Theme [as 别名]
# 或者: from theme.Theme import get_surface [as 别名]

#.........这里部分代码省略.........

        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
        elif pix1 in self.temp:
开发者ID:valentt,项目名称:Fusion-Linux-Extras,代码行数:70,代码来源:iconfactory.py


注:本文中的theme.Theme.get_surface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。