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


Python svgitem.SvgItem方法代码示例

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


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

示例1: set_svg_icon

# 需要导入模块: import svgitem [as 别名]
# 或者: from svgitem import SvgItem [as 别名]
def set_svg_icon(self, file_base_name, width=None, height=None, align_x=0.5, align_y=0.5):
        """
        Set a background SVG icon for the node.

        @param file_base_name: base file name, including .svg
        extension, of the svg file.  Place the file in the folder
        src/contrib/visualizer/resource.
        
        @param width: scale to the specified width, in meters
        @param width: scale to the specified height, in meters

        @param align_x: horizontal alignment of the icon relative to
        the node position, from 0 (icon fully to the left of the node)
        to 1.0 (icon fully to the right of the node)

        @param align_y: vertical alignment of the icon relative to the
        node position, from 0 (icon fully to the top of the node) to
        1.0 (icon fully to the bottom of the node)

        """
        if width is None and height is None:
            raise ValueError("either width or height must be given")
        rsvg_handle = svgitem.rsvg_handle_factory(file_base_name)
        x = self.canvas_item.props.center_x
        y = self.canvas_item.props.center_y
        self.svg_item = svgitem.SvgItem(x, y, rsvg_handle)
        self.svg_item.props.parent = self.visualizer.canvas.get_root_item()
        self.svg_item.props.pointer_events = 0
        self.svg_item.lower(None)
        self.svg_item.props.visibility = goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD
        if width is not None:
            self.svg_item.props.width = transform_distance_simulation_to_canvas(width)
        if height is not None:
            self.svg_item.props.height = transform_distance_simulation_to_canvas(height)

        #threshold1 = 10.0/self.svg_item.props.height
        #threshold2 = 10.0/self.svg_item.props.width
        #self.svg_item.props.visibility_threshold = min(threshold1, threshold2)

        self.svg_align_x = align_x
        self.svg_align_y = align_y
        self._update_svg_position(x, y)
        self._update_appearance() 
开发者ID:ntu-dsi-dcn,项目名称:ntu-dsi-dcn,代码行数:45,代码来源:core.py

示例2: set_svg_icon

# 需要导入模块: import svgitem [as 别名]
# 或者: from svgitem import SvgItem [as 别名]
def set_svg_icon(self, file_base_name, width=None, height=None, align_x=0.5, align_y=0.5):
        """!
        Set a background SVG icon for the node.

        @param file_base_name: base file name, including .svg
        extension, of the svg file.  Place the file in the folder
        src/contrib/visualizer/resource.
        
        @param width: scale to the specified width, in meters
        @param height: scale to the specified height, in meters

        @param align_x: horizontal alignment of the icon relative to
        the node position, from 0 (icon fully to the left of the node)
        to 1.0 (icon fully to the right of the node)

        @param align_y: vertical alignment of the icon relative to the
        node position, from 0 (icon fully to the top of the node) to
        1.0 (icon fully to the bottom of the node)

        @return a ValueError exception if invalid dimensions.

        """
        if width is None and height is None:
            raise ValueError("either width or height must be given")
        rsvg_handle = svgitem.rsvg_handle_factory(file_base_name)
        x = self.canvas_item.props.center_x
        y = self.canvas_item.props.center_y
        self.svg_item = svgitem.SvgItem(x, y, rsvg_handle)
        self.svg_item.props.parent = self.visualizer.canvas.get_root_item()
        self.svg_item.props.pointer_events = 0
        self.svg_item.lower(None)
        self.svg_item.props.visibility = goocanvas.ITEM_VISIBLE_ABOVE_THRESHOLD
        if width is not None:
            self.svg_item.props.width = transform_distance_simulation_to_canvas(width)
        if height is not None:
            self.svg_item.props.height = transform_distance_simulation_to_canvas(height)

        #threshold1 = 10.0/self.svg_item.props.height
        #threshold2 = 10.0/self.svg_item.props.width
        #self.svg_item.props.visibility_threshold = min(threshold1, threshold2)

        self.svg_align_x = align_x
        self.svg_align_y = align_y
        self._update_svg_position(x, y)
        self._update_appearance() 
开发者ID:KTH,项目名称:royal-chaos,代码行数:47,代码来源:core.py


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