title: PyQt pushbutton to upload file
body: <p>I wanted to implement a pushbutton that allows me to select from various input files and upload the one of my choice. I searched online and put together some code, the problem is, I dont exactly understand how I would implement the fileDialogue within a slot. The code you see inside the slot "on_click" is taken directly from an online example and its not really working. The main issue is that getOpenFileName requires one of the arguments to be "self", Im not sure I know how to use "self" within a PyQt slot. Thanks for the help</p>
  
  <pre><code>import sys
  from PyQt4 import QtGui,QtCore
  from PyQt4.QtCore import pyqtSlot
  from PyQt4.QtGui import *
  
  @pyqtSlot()
  def on_click():
          filename = QtGui.QFileDialog.getOpenFileName(self,'Open File', '.')
          fname = open(filename)
          data = fname.read()
          self.textEdit.setText(data)
          fname.close()
  
  
  
  class MainWindow(QtGui.QWidget):
          def __init__(self):     #try removing parent=None
                  QtGui.QWidget.__init__(self)
                  self.setGeometry(650,300,600,600)
                  self.setWindowTitle("Data Viewer")
  
  
                  quitB = QtGui.QPushButton("QUIT",self)
                  uploadB = QtGui.QPushButton("UPLOAD",self)
  
                  hbox = QHBoxLayout()
  
  
  
  
  self.connect(quitB,QtCore.SIGNAL('clicked()'),QtGui.qApp,QtCore.SLOT('quit()'))
                  uploadB.clicked.connect(on_click(self))
  
                  #add buttons to horizontal box layout
                  hbox.addWidget(quitB)
                  hbox.addWidget(uploadB)
                  self.setLayout(hbox)
  def main():
          app = QtGui.QApplication(sys.argv)
          mw = MainWindow()
          mw.show()
          sys.exit(app.exec_())
  
  
  if __name__ == "__main__":
          main()
  </code></pre>