當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。