addition of a method setColor for TextItem
This commit is contained in:
parent
865141ae49
commit
b7efa546aa
@ -50,8 +50,8 @@ class TextItem(GraphicsObject):
|
|||||||
self._lastTransform = None
|
self._lastTransform = None
|
||||||
self._bounds = QtCore.QRectF()
|
self._bounds = QtCore.QRectF()
|
||||||
if html is None:
|
if html is None:
|
||||||
self.color = color
|
self.setColor(color)
|
||||||
self.setText(text, color)
|
self.setText(text)
|
||||||
else:
|
else:
|
||||||
self.setHtml(html)
|
self.setHtml(html)
|
||||||
self.fill = fn.mkBrush(fill)
|
self.fill = fn.mkBrush(fill)
|
||||||
@ -64,10 +64,6 @@ class TextItem(GraphicsObject):
|
|||||||
|
|
||||||
This method sets the plain text of the item; see also setHtml().
|
This method sets the plain text of the item; see also setHtml().
|
||||||
"""
|
"""
|
||||||
if color != self.color:
|
|
||||||
color = self.color
|
|
||||||
color = fn.mkColor(color)
|
|
||||||
self.textItem.setDefaultTextColor(color)
|
|
||||||
self.textItem.setPlainText(text)
|
self.textItem.setPlainText(text)
|
||||||
self.updateTextPos()
|
self.updateTextPos()
|
||||||
|
|
||||||
@ -117,6 +113,16 @@ class TextItem(GraphicsObject):
|
|||||||
def setAnchor(self, anchor):
|
def setAnchor(self, anchor):
|
||||||
self.anchor = Point(anchor)
|
self.anchor = Point(anchor)
|
||||||
self.updateTextPos()
|
self.updateTextPos()
|
||||||
|
|
||||||
|
def setColor(self, color):
|
||||||
|
"""
|
||||||
|
Set the color for this text.
|
||||||
|
|
||||||
|
See QtGui.QGraphicsItem.setDefaultTextColor().
|
||||||
|
"""
|
||||||
|
self.color = fn.mkColor(color)
|
||||||
|
self.textItem.setDefaultTextColor(self.color)
|
||||||
|
self.updateTextPos()
|
||||||
|
|
||||||
def updateTextPos(self):
|
def updateTextPos(self):
|
||||||
# update text position to obey anchor
|
# update text position to obey anchor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user