HTML for infiniteline

31 views
Skip to first unread message

Szilard Perenyi

unread,
Jan 31, 2019, 12:01:42 PM1/31/19
to pyqtgraph
Hi, is it possible to write the label in HTML code for the infiniteline?
Message has been deleted

Szilard Perenyi

unread,
Jan 31, 2019, 12:07:34 PM1/31/19
to pyqtgraph
Basically something like this, but this doesnt work.
OrderLine = pg.InfiniteLine(pos=price, movable=True, angle=0, pen=pen, label=("<span style='font-size: 10pt;color:#b3ffb3'>%s</span>" % (Quantity)) , labelOpts={'position': .890, 'anchors': [0,0], 'fill': bg, 'movable': True} )

Patrick

unread,
Feb 3, 2019, 7:15:51 PM2/3/19
to pyqtgraph
Hi,

The code for the valueChanged event in InfLineLabel (http://www.pyqtgraph.org/documentation/_modules/pyqtgraph/graphicsItems/InfiniteLine.html#InfiniteLine) uses the setText method inherited from TextItem (http://www.pyqtgraph.org/documentation/graphicsItems/textitem.html#pyqtgraph.TextItem.setText). I see two possible options.
1. If you just want to set the size and colour of the label, then try using the setFont and setColor methods, something like OrderLine.label.setFont(....) and OrderLine.label.setColor(...), but you'll need to look up the PyQt documents for usage, as these wrap the underlying Qt methods.
2. Do a dirty hack on the code, and change the setText to setHtml in the valueChanged method of InfLineLabel. Not ideal, but might work.

Patrick
Reply all
Reply to author
Forward
0 new messages