title: Pyside: How to use QInputDialog.getText
body: <p>I am new to PySide and I am trying to have a user enter some text. I want to then store it in a variable and use it in a search through a separate script that I have. The search script that I have parses though a text file looking for keywords that the user would have entered. First things first, I am trying to get the input text to store in a variable, and I'm testing to see if its stored by using a simple print statement.</p>
  
  <p>As you will see below, I've set it up so that an input box pops up and the user enters some text. But then if I call the print outside of <code>showDialog</code> nothing prints. If I print within the <code>showDialog</code> it works fine. Why wont it print outside the function?</p>
  
  <p>If there's a better way to do this please feel free to educate me.</p>
  
  <pre><code>import sys
  from PySide import QtGui
  
  class Example(QtGui.QWidget):
  
      def __init__(self):
          super(Example, self).__init__()
  
          self.initUI()
  
      def initUI(self):
          self.btn = QtGui.QPushButton('test', self)
          self.btn.move(20, 20)
          self.btn.clicked.connect(self.showDialog)
  
          self.setGeometry(300, 300, 290, 150)
          self.setWindowTitle('Input dialog')
          self.show()
  
  
      start = ''
      end = ''
      number = ''
  
      def showDialog(self):
          global start
          start = start, ok = QtGui.QInputDialog.getText(self, 'text',
                                                 'Enter some text')
          global end
          end = end, ok = QtGui.QInputDialog.getText(self, "text",
                                           "Enter some text")
          global number
          number = number, ok = QtGui.QInputDialog.getText(self, "text",
                                                  "Enter some text")
  
      # I'm trying to print out the text stored from the input variables.
      print start
      print end
      print number
  
  def main():
      app = QtGui.QApplication(sys.argv)
      ex = Example()
      sys.exit(app.exec_())
  
  if __name__ == '__main__':
      main()
  </code></pre>