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


Python Theme.get_aspect_ratio方法代码示例

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


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

示例1: IconFactory

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

#.........这里部分代码省略.........
        return self.size

    def get_icon(self, size):
        return self.__find_icon_pixbuf(size)

    def reset_icon(self):
        self.icon = None

    def reset_surfaces(self, arg=None):
        self.surfaces = {}
        self.average_color = None


    def surface_update(self, type = 0):
        # Checks if the requested pixbuf is already
        # drawn and returns it if it is.
        # Othervice the surface is drawn, saved and returned.

        #The first four bits of type is for telling the number of windows
        self.win_nr = min(type & 15, self.max_win_nr)
        # Remove all types that are not used by the theme (saves memory)
        dnd = (type & self.DRAG_DROPP_START and "start") or \
              (type & self.DRAG_DROPP_END and "end")
        type = type & self.types_in_theme
        type += self.win_nr
        self.orient = self.dockbar_r().orient
        is_vertical = self.orient in ("left", "right")
        if type in self.surfaces:
            surface = self.surfaces[type]
        else:
            self.temp = {}
            surface = None
            commands = self.theme.get_icon_dict()
            self.ar = self.theme.get_aspect_ratio(is_vertical)
            self.type = type
            for command, args in commands.items():
                try:
                    f = getattr(self, "_IconFactory__command_%s"%command)
                except:
                    raise
                else:
                    surface = f(surface, **args)
            # Todo: add size correction.
            self.surfaces[type] = surface
            del self.temp
            gc.collect()
        if dnd:
            surface = self.__dd_highlight(surface, self.orient, dnd)
            gc.collect()
        return surface


    def __dd_highlight(self, surface, is_vertical, position="start"):
        w = surface.get_width()
        h = surface.get_height()
        if is_vertical:
            h = h + 4
        else:
            w = w + 4
        bg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
        ctx = cairo.Context(bg)

        if is_vertical and position == "start":
            ctx.move_to(1, 1.5)
            ctx.line_to(w - 1, 1.5)
            ctx.set_source_rgba(1, 1, 1, 0.2)
开发者ID:M7S,项目名称:dockbarx,代码行数:70,代码来源:iconfactory.py

示例2: IconFactory

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

#.........这里部分代码省略.........
    def set_size(self, size):
        if size <= 0:
            # To avoid chrashes.
            size = 15
        self.size = size
        self.surfaces = {}
        self.average_color = None

    def get_size(self):
        return self.size

    def reset_surfaces(self, arg=None):
        self.surfaces = {}
        self.average_color = None


    def surface_update(self, type = 0):
        # Checks if the requested pixbuf is already
        # drawn and returns it if it is.
        # Othervice the surface is drawn, saved and returned.

        #The first four bits of type is for telling the number of windows
        self.win_nr = min(type & 15, self.max_win_nr)
        # Remove all types that are not used by the theme (saves memory)
        dnd = type & self.DRAG_DROPP
        type = type & self.types_in_theme
        type += self.win_nr
        if type in self.surfaces:
            surface = self.surfaces[type]
        else:
            self.temp = {}
            surface = None
            commands = self.theme.get_icon_dict()
            self.ar = self.theme.get_aspect_ratio()
            self.type = type
            for command, args in commands.items():
                try:
                    f = getattr(self,"command_%s"%command)
                except:
                    raise
                else:
                    surface = f(surface, **args)
            # Todo: add size correction.
            self.surfaces[type] = surface
            del self.temp
            gc.collect()
        if dnd:
            surface = self.dd_highlight(surface, self.globals.orient)
            gc.collect()
        return surface


    def dd_highlight(self, surface, direction = 'h'):
        w = surface.get_width()
        h = surface.get_height()
        # Make a background almost twice as wide or high
        # as the surface depending on panel orientation.
        if direction == 'v':
            h = h + 4
        else:
            w = w + 4
        bg = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h)
        ctx = cairo.Context(bg)

        # Put arrow pointing to the empty part on it.
        if direction == 'v':
开发者ID:valentt,项目名称:Fusion-Linux-Extras,代码行数:70,代码来源:iconfactory.py


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