def __init__(self, scene=None):
if scene is None:
scene = TurtleScene()
self._scene = scene
super().__init__(scene)
transform = QtGui.QTransform(
1, 0,
0, -1, # Revert y, so it uses the standard axis convention in maths
0, 0
)
self.setTransform(transform)
self._zoomfactor = 1.2
# This will crash if I put it in the module namespace, probably
# because the QApplication instance does not exist yet
_LABEL_HEIGHT = QtGui.QFontMetrics(
_LABEL_FONT).height() + 2 * _LABEL_PADDING
w = self._posLabel = QtWidgets.QLabel(self)
# http://stackoverflow.com/questions/7928519/how-to-make-the-qlabel-background-semi-transparent
# Fourth parameter in color tuple is alpha: 0-transparent; 255-opaque
w.setStyleSheet('color: rgba(0, 0, 0, 196); '
'background-color: rgba(0, 0, 0, 0);'
'padding: %d' % _LABEL_PADDING)
w.setAlignment(QtCore.Qt.AlignRight)
w.setFont(_LABEL_FONT)
w.setGeometry(0, 0, 100, _LABEL_HEIGHT)
self._updatePosLabelText((0, 0))
self._updatePosLabelPosition()
评论列表
文章目录