PlotItem.autoBtnClicked to emit PlotItem.sigRangeChangedManually#3049
Conversation
|
Here is a script to test the added feature. import numpy as np
from PyQt6.QtCore import pyqtSlot
import pyqtgraph as pg
app = pg.mkQApp("Plotting Example")
win = pg.GraphicsLayoutWidget(show=True, title="Basic plotting examples")
p1 = win.addPlot(y=np.random.normal(size=100))
p1.vb.setMouseEnabled(True, True)
@pyqtSlot(object)
def rangeChangedManually(mask):
print(f'sigRangeChangedManually emitted ({mask})')
p1.sigRangeChangedManually.connect(rangeChangedManually)
if __name__ == "__main__":
pg.exec()edited 7/3: updated the signal connection to the PlotItem instead of ViewBox |
|
Thanks for the PR, sorry for the long wait to reply, I recently had a large move. My first question is why emit the signal inside the PlotItem instance, but not have it emitted as part of |
|
@j9ac9k - I'm glad you got around to my PRs. Thanks for reviewing them.
Because it was the path of the least resistance although I agree with you on its awkwardness. I didn't think it would be appropriate for Hope this makes sense. I'm 100% open to your suggestions/decisions and will be happy to modify the PR accordingly. |
|
Actually you can chain signals together so we can just tie this signal to the signal that is emitted when the button is pressed. I'm on mobile right now so I can't look it up but maybe that signal makes more sense there? |
…ox.sigRangeChangedManually
2d783b1 to
a4f54ec
Compare
- chained to ViewBox.sigRangeChangedManually changed to emit this signal instead of the viewbox one
|
Yes, I was thinking that just after I posted last night. I checked |
|
Sorry for the long wait on merging this @tikuma-lsuhsc This PR LGTM, merging. Thanks for the contribution to the library! |
…tgraph#3049) * PlotItem.autoBtnClicked changes range via user interface - emit ViewBox.sigRangeChangedManually * fixed error * added PlotItem.sigRangeChangedManually - chained to ViewBox.sigRangeChangedManually changed to emit this signal instead of the viewbox one * updated doc --------- Co-authored-by: Takeshi Ikuma <tikuma@gmail.com>
As all the mouse interactions in
ViewBoxemitsViewBox.sigRangeChangedManually, it seems logical for pressing the "auto" button onPlotItemto also emit this signal.