title: Selecting points on a PlotWidget with Qt
body: <p>I'm new to python/pyside/pyqtgraph and I'm kind of stuck in my program.</p>
  
  <p>So, I have an numpy.ndarray representing 10000 values, and I plot it in a PlotWidget using the plot method.
  The result is ok but now I want to allow the user to select points of the curve so I can save the X axis of the point and use it later on.</p>
  
  <p>What I would like to do is creating a QPushButton which when clicked it waits for the user to select two points on the curve by left-clicking and then save the X axis. Seems pretty simple conceptually but I don't find the good way of doing it. 
  I would be really pleased if you could give me an example or something, I'm also open to any suggestion that deviate from this use case.</p>
  
  <p>I can resume the code by this lines : </p>
  
  <pre><code>self.myWidget = pyqtgraph.PlotWidget()
  self.myWidget.plot(myValues) # myValues is the numpy array
  self.select2PointsButton = QtGui.QPushButton()
  self.select2PointsButton.clicked.connect(self.waitForSelection)
  
  def waitForSelection(self):
  # Wait for a click left on the curve to select first point then save the X-axis
  # Do it again to select the second point
  </code></pre>
  
  <p>Thanks,
  Morgan</p>
  
  <p><strong>Edit after Zet4 answer :</strong> </p>
  
  <p>Thank you for your answer it helped me get started.
  In the end, I made a subclass of PlotWidget :</p>
  
  <pre><code>class PltWidget(pg.PlotWidget):
  
  def __init__(self, parent=None):
      super(PltWidget, self).__init__(parent)
      self.selectionMode = False
  
  def mousePressEvent(self, ev):
      if self.selectionMode:
          if ev.button() == QtCore.Qt.LeftButton:
              # How do I get the X axis ?
      else:
          super(PltWidget, self).mousePressEvent(ev)
  </code></pre>
  
  <p>Then I use it in my window, connecting the button signal with the slot changing the boolean of my PltWidget :</p>
  
  <pre><code>..... # Other attributes and connections of my Window
  self.T0Button = QtGui.QPushButton()
  self.graphicsLeft = PltWidget()
  self.T0Button.clicked.connect(self.selectT0)
  
  def selectT0(self):
      self.graphicsLeft.selectionMode = not(self.graphicsLeft.selectionMode)
  </code></pre>
  
  <p>I'll probably use your buffer strategy to command two selections from the user.
  However, I still need to know how do I get the X axis of the PlotWidget from where I clicked. If anyone using pyqtgraph know the answer, please let me know. 
  Thanks.</p>