Merge pull request #291 from lesauxvi/textitem
slight changes in TextItem
This commit is contained in:
commit
0ac914fae7
@ -11,11 +11,16 @@ pyqtgraph-0.9.11 [unreleased]
|
|||||||
- Remove all modifications to builtins
|
- Remove all modifications to builtins
|
||||||
- Fix SpinBox decimals
|
- Fix SpinBox decimals
|
||||||
|
|
||||||
|
API / behavior changes:
|
||||||
|
- Change the defaut color kwarg to None in TextItem.setText() to avoid changing
|
||||||
|
the color everytime the text is changed.
|
||||||
|
|
||||||
New Features:
|
New Features:
|
||||||
- Preliminary PyQt5 support
|
- Preliminary PyQt5 support
|
||||||
- DockArea:
|
- DockArea:
|
||||||
- Dock titles can be changed after creation
|
- Dock titles can be changed after creation
|
||||||
- Added Dock.sigClosed
|
- Added Dock.sigClosed
|
||||||
|
- Added TextItem.setColor()
|
||||||
|
|
||||||
Maintenance:
|
Maintenance:
|
||||||
- Add examples to unit tests
|
- Add examples to unit tests
|
||||||
|
@ -50,21 +50,22 @@ 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.setText(text, color)
|
self.setColor(color)
|
||||||
|
self.setText(text)
|
||||||
else:
|
else:
|
||||||
self.setHtml(html)
|
self.setHtml(html)
|
||||||
self.fill = fn.mkBrush(fill)
|
self.fill = fn.mkBrush(fill)
|
||||||
self.border = fn.mkPen(border)
|
self.border = fn.mkPen(border)
|
||||||
self.setAngle(angle)
|
self.setAngle(angle)
|
||||||
|
|
||||||
def setText(self, text, color=(200,200,200)):
|
def setText(self, text, color=None):
|
||||||
"""
|
"""
|
||||||
Set the text and color of this item.
|
Set the text of this item.
|
||||||
|
|
||||||
This method sets the plain text of the item; see also setHtml().
|
This method sets the plain text of the item; see also setHtml().
|
||||||
"""
|
"""
|
||||||
color = fn.mkColor(color)
|
if color is not None:
|
||||||
self.textItem.setDefaultTextColor(color)
|
self.setColor(color)
|
||||||
self.textItem.setPlainText(text)
|
self.textItem.setPlainText(text)
|
||||||
self.updateTextPos()
|
self.updateTextPos()
|
||||||
|
|
||||||
@ -115,6 +116,15 @@ class TextItem(GraphicsObject):
|
|||||||
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)
|
||||||
|
|
||||||
def updateTextPos(self):
|
def updateTextPos(self):
|
||||||
# update text position to obey anchor
|
# update text position to obey anchor
|
||||||
r = self.textItem.boundingRect()
|
r = self.textItem.boundingRect()
|
||||||
|
Loading…
Reference in New Issue
Block a user