I am trying to get all values of the object pg.InfiniteLine() using getXPos() method.
I tried the following (this code snippet is set inside of class MainWindow(QMainWindow)):
inf = pg.InfiniteLine(movable=True, angle=90, label='x={value:.3f}:{value:.3f}',
labelOpts={'position':0.1, 'color': (200,200,100), 'fill': (200,200,200,50), 'movable': True})
inf.setPos([0,0])
self.graphWidget.addItem(inf)
Note: value in label='{value:.3f}:{value:.3f}' is after converting a list of strings t_string_list[:5] = ['0:0', '0:1', '0:2', '0:3', '0:4'] (of format H:M) to minutes stored in a variable t_time_value.
What I am trying to do is that label be set back to x=H:M displayed in the graph. To do that, I am trying to get all values of getXPos() for me to use Converting a float to hh:mm format.
I tried to do print(inf.getXPos()) but prints only 0. I also tried print(inf.getXPos(t_time_value)) I got TypeError: getXPos() takes 1 positional argument but 2 were given. I am not sure how to label the InfiniteLine with x=H:M where H:M should be values using label='{value:.3f}:{value:.3f}'.format(*divmod(pos / 60, 1)) argument of inf where I am facing difficulties to define pos.
This post is continuous to How to plot hour:min time in ISO 8601 time format?
Note: label='{value:.3f}:{value:.3f}' already gives correct positions whenever I move the line, but I couldn't do like this label='{value:.3f}:{value:.3f}'.format(value/60, 1) because value isn't defined.