title: PyQt: Adding user input into list
body: <p>I am trying to make a list box where a user can enter more items to the list. I have a list box set up with an add button. The add button opens up a user input box where it will direct the user to enter a value. However, I am have issue with passing on the value of user input to the add onto the list. Any suggestions would help. Below is my code:</p>
  
  <p><strong>List box</strong></p>
  
  <pre><code>from input_box import *
  
  class list_form(QtGui.QWidget):
  
      def __init__(self,list_of_items,open_text,parent= None):
          super(list_form, self).__init__()
  
          global output_path
          output_path = output_path_i
  
          grid = QtGui.QGridLayout()
          grid.setSpacing(10)
          self.widget = QtGui.QWidget()
  
          self.layout = QtGui.QGridLayout(self.widget)
          open_message = QtGui.QLabel(open_text)
          grid.addWidget(open_message,0,0,2,4)
  
          self.lst = QtGui.QListWidget()
          grid.addWidget(self.lst,3, 0,1,4)
  
          for i in list_of_items:
              self.lst.addItem(str(i))
  
          self.setLayout(grid)
  
          add = QtGui.QPushButton('Add')
          grid.addWidget(add,50,0)
          add.clicked.connect(self.add_button)
  
      def add_button(self):
          self.input_box = input_box()
          self.input_box.setWindowTitle("Window 2")
          self.input_box.show()
  
  if __name__ == "__main__":
      app = QtGui.QApplication(sys.argv)
      window = list_form(list(xrange(100)),"List of Values")
      window.setWindowTitle('Window 1')
      window.show()
      sip.setdestroyonexit(False)
      sys.exit(app.exec_())
  </code></pre>
  
  <p><strong>Input box</strong></p>
  
  <pre><code>import sys
  from PyQt4 import QtCore, QtGui
  import sip
  
  class input_box(QtGui.QWidget):
  
      def __init__(self,parent= None):
          super(input_box, self).__init__()
  
          grid = QtGui.QGridLayout()
          grid.setSpacing(10)
          self.widget = QtGui.QWidget()
  
          self.layout = QtGui.QGridLayout(self.widget)
          open_message = QtGui.QLabel("Enter Value:")
          grid.addWidget(open_message,0,0,2,3)
  
          self.txt = QtGui.QLineEdit()
          grid.addWidget(self.txt,2, 0,1,2)
  
          self.setLayout(grid)
  
          save = QtGui.QPushButton('Save')
          grid.addWidget(save,50,0)
          a = save.clicked.connect(self.save)
          save.clicked.connect(self.close)
  
          cancel = QtGui.QPushButton('Cancel')
          grid.addWidget(cancel,50,1)
          cancel.clicked.connect(self.close)
  
  
      def save(self):
          value = self.txt.text()
          return value
  </code></pre>