本文整理汇总了Python中line.Line.setOrigin方法的典型用法代码示例。如果您正苦于以下问题:Python Line.setOrigin方法的具体用法?Python Line.setOrigin怎么用?Python Line.setOrigin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类line.Line
的用法示例。
在下文中一共展示了Line.setOrigin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Tick
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import setOrigin [as 别名]
#.........这里部分代码省略.........
Parent.__init__(self)
self._tickMark = Line(canvas, **tickMarkProps)
self._label = Text(canvas, **labelProps)
self._axis = axis
self.addChild(self._tickMark)
self.addChild(self._label)
# Location where the tick should be placed, in data coords
self._dataLocation = dataLoc
self._length = 5
self.setLength(length)
self._direction = 'in'
self.setDirection(direction)
def setLabel(self, text=None, **kwprops):
"""
Update the label Text object with the passed text and kwprops.
If text is not a string, then the label's text will not be changed.
If both text and kwprops['text'] are defined, the text argument takes precedence.
"""
if isinstance(text, str):
kwprops['text'] = text
self._label.setProps(**kwprops)
def setLength(self, length):
"""
Update the length of the tick mark. The length must be an int.
"""
if isinstance(length, int):
self._length = length
def setDirection(self, direction):
"""
Update the direction of the tick mark. The direction must be either 'in'
or 'out', and refers to whether the tick mark should be inside or outside
the plot. The label will always be outside.
"""
if direction in ('in', 'out', 'both'):
self._direction = direction
def setTickMarkProps(self, **kwprops):
"""Update the tick mark Line object with the passed kwprops."""
self._tickMark.setProps(**kwprops)
def setTickPosition(self):
"""
Set the position, in plot coordinates, of both the tick mark Line object
and the label Text object.
"""
# Determine various points in plot coordinates
plotLocation = self._axis.mapDataToPlot(self._dataLocation)
labelPosition = self._axis._plotAnchor
startPosition = self._axis._plotAnchor
endPosition = startPosition
if self._axis.inside() == 'up' and self._direction == 'in':
endPosition = startPosition + self._length
elif self._axis.inside() == 'up' and self._direction == 'out':
endPosition = startPosition - self._length
elif self._axis.inside() == 'up' and self._direction == 'both':
endPosition = startPosition - self._length
startPosition += self._length
elif self._axis.inside() == 'down' and self._direction == 'in':
endPosition = startPosition - self._length
elif self._axis.inside() == 'down' and self._direction == 'out':
endPosition = startPosition + self._length
elif self._axis.inside() == 'down' and self._direction == 'both':
endPosition = startPosition + self._length
startPosition -= self._length
self._tickMark.setOrigin(self._axis._ox, self._axis._oy)
self._label.setOrigin(self._axis._ox, self._axis._oy)
# Actually set the positions of the tick mark and label
if self._axis.orientation() == 'horizontal':
self._tickMark.setPosition(plotLocation, startPosition)
self._tickMark.setEnd(plotLocation, endPosition)
self._label.setPosition(plotLocation, labelPosition)
elif self._axis.orientation() == 'vertical':
self._tickMark.setPosition(startPosition, plotLocation)
self._tickMark.setEnd(endPosition, plotLocation)
self._label.setPosition(labelPosition, plotLocation)
def remove(self):
"""Remove both the tick mark and the label from the figure."""
self._tickMark.remove()
self._label.remove()
def draw(self):
"""Draw both the tick mark and the label."""
self._tickMark.draw()
self._label.draw()
示例2: setOrigin
# 需要导入模块: from line import Line [as 别名]
# 或者: from line.Line import setOrigin [as 别名]
def setOrigin(self, x=0, y=0):
"""
Set the origin, using figure coordinates.
"""
Line.setOrigin(self, x, y)
self.setLabelOrigin()