Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add crosshair after LivePlotWidget constructor called #27

Closed
veractor opened this issue Aug 13, 2023 · 2 comments
Closed

Comments

@veractor
Copy link

When using QtDesigner to design a GUI, the construction of the widgets is done in the generated UI class (if pyuic was used), which means that we don't have a chance to specify any constructor arguments if we don't touch that file.

So after looking through the source code a bit, I've found the only way to add a crosshair to a LivePlotWidget after construction is to do something like this:

widget.crosshair_enabled = True
widget._add_crosshair(pg.mkPen(color='red', width=1), {'color': 'green'})

But this clearly violates encapsulation. Shouldn't there be some way to add a crosshair after construction that would not require calling a privated method?

I believe this was the original motivation behind #13 as well.

@domarm-comat
Copy link
Owner

Thanks for your comment on this matter.

Yes, adding crosshair after LivePlotWidget was constructed was not straightforward.

I've refactor crosshair code a bit. _add_crosshair became add_crosshair. Now you can simply use:
widget.add_crosshair(pg.mkPen(color='red', width=1), {'color': 'green'})

I also added method widget.remove_crosshair() to easilly remove crosshair from the plot.

It should be available to you in version 0.6.8.

@veractor
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants