pyqtgraph InfiniteLine's width changes on mouse hover.

263 views
Skip to first unread message

Manish

unread,
May 9, 2014, 5:47:04 AM5/9/14
to pyqt...@googlegroups.com
Hi,
 
I am setting the width of InfiniteLine by setting the width of the pen. But on mousehover on InfiniteLine the width changes and the line becomes thin. I checked in the InfineLine .py file to understand this behavior and found out that on mouse hover the pen is changed to mkPen(255, 0,0) and hence the width changes to default value.
I want to know is there any specific reasion to set pen without considering the pen width provided as input or is it a bug.

Manish

unread,
May 9, 2014, 8:14:19 AM5/9/14
to pyqt...@googlegroups.com
I made a custom class which inherits from the the InfinteLine and have overridden the setMouseHover method to do nothing on mousehover and then I have set the width of InfiniteLine.
But I am facing following issues now.
1. On zooming in and out the width of InfiniteLine increases and decreases.
2. On moving it in a zoomed stage it moves only when the mouse is perfectly at it's center. Some times the line spread on the plot while moving.
Please refer to sample code.
##############
class MyLine(pg.InfiniteLine):

def __init__(self, pos, angle, pen=QtGui.QPen(QtGui.QColor('#FFFF00'), 5),

movable=True):

pg.InfiniteLine.__init__(self, pos, angle, pen=pen, movable=True)

 

def setMouseHover(self, hover):

pass

 

########

app = pg.mkQApp()

pw = pg.GraphicsLayoutWidget()

pw.show()

w1 = pw.addPlot()

a = MyLine(50 , 90, pen = pen)

w1.addItem(a)

app.exec_()

Luke Campagnola

unread,
May 10, 2014, 2:20:54 PM5/10/14
to pyqt...@googlegroups.com
On Fri, May 9, 2014 at 5:47 AM, Manish <monkm...@gmail.com> wrote:
I am setting the width of InfiniteLine by setting the width of the pen. But on mousehover on InfiniteLine the width changes and the line becomes thin. I checked in the InfineLine .py file to understand this behavior and found out that on mouse hover the pen is changed to mkPen(255, 0,0) and hence the width changes to default value.
I want to know is there any specific reasion to set pen without considering the pen width provided as input or is it a bug.

Not exactly a bug, more of a missing feature, since there is no way for the user to specify the pen to use on mouse hover.
I have added a setHoverPen method to InfiniteLine; this will appear in the next release.

Thanks!

Luke Campagnola

unread,
May 10, 2014, 2:25:57 PM5/10/14
to pyqt...@googlegroups.com
On Fri, May 9, 2014 at 8:14 AM, Manish <monkm...@gmail.com> wrote:

On Friday, May 9, 2014 3:17:04 PM UTC+5:30, Manish wrote:
Hi,
 
I am setting the width of InfiniteLine by setting the width of the pen. But on mousehover on InfiniteLine the width changes and the line becomes thin. I checked in the InfineLine .py file to understand this behavior and found out that on mouse hover the pen is changed to mkPen(255, 0,0) and hence the width changes to default value.
I want to know is there any specific reasion to set pen without considering the pen width provided as input or is it a bug.
 
I made a custom class which inherits from the the InfinteLine and have overridden the setMouseHover method to do nothing on mousehover and then I have set the width of InfiniteLine.
But I am facing following issues now.
1. On zooming in and out the width of InfiniteLine increases and decreases.
2. On moving it in a zoomed stage it moves only when the mouse is perfectly at it's center. Some times the line spread on the plot while moving.

I am not able to reproduce these using the code you provided. Can you tell me the output of pg.systemInfo() on your machine?
 
Reply all
Reply to author
Forward
0 new messages