title: PyQt: connecting widget with a function with argument
body: <p>So, I found out it can be done using python's <code>lambda</code>, but the problem is, if I put a variable inside <code>lambda</code>, it will take it's last value, which I don't want to happen. So, is this possible to do with for loop or I need to do it manually?
  Short code example is here:</p>
  
  <pre><code>import os,sys,time
  from PyQt4 import QtGui, QtCore
  
  class Widget(QtGui.QWidget):
      def __init__(self):
          super(Widget,self).__init__()
          self.setGeometry(50,50,600,300)
          self.setWindowTitle("Example")
  
          self.btns=[]
          layout=QtGui.QHBoxLayout()
  
          for i in range(5):
              self.btns.append(QtGui.QPushButton(str(i),self))
              self.btns[i].pressed.connect(lambda: self.example(i))
              layout.addWidget(self.btns[i])
  
          self.setLayout(layout)
          self.show()
  
      def example(self,i):
          print(i)#no matter which button is clicked, it prints 4 in this example
  
  
  app=QtGui.QApplication(sys.argv)
  GUI=Widget()
  sys.exit(app.exec_())
  </code></pre>