How to pass QLineEdit value to another function?
<p>I'm using Python 2.7 and PyQT4, I'm making a simple calculator, I have two <code>QLineEdit</code> and I have a function that prints the result of adding.</p>

<pre><code>class Window(QtGui.QMainWindow):
    global number_1_text
    global number_2_text

    def __init__(self):
        super(Window, self).__init__()
        self.setWindowFlags(QtCore.Qt.WindowMinimizeButtonHint)
        #Main Window Settings
        self.setGeometry(50,50,500,300)
        self.setWindowTitle("Point of sale !")
        self.setWindowIcon(QtGui.QIcon('python.png'))

        #Close Action
        exitAction = QtGui.QAction(QtGui.QIcon('python.png'),"Close Now !", self)
        exitAction.setShortcut("Ctrl+Q")
        exitAction.setStatusTip('Leave the Application')
        exitAction.triggered.connect(self.close_application)
        self.statusBar()

        #Menubar
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('&amp;File')
        fileMenu.addAction(exitAction)


        # Create textboxs
        number_1 = QtGui.QLineEdit(self)
        number_1.move(20, 50)
        number_1.resize(380,40)
        self.number_1_text = number_1.text()

        number_2 = QtGui.QLineEdit(self)
        number_2.move(20, 100)
        number_2.resize(380,40)
        self.number_2_text = number_2.text()

        #Main Home Proccess
        quiteBtn = QtGui.QPushButton("Quite", self)
        quiteBtn.resize(100, 50)
        quiteBtn.move(50,220)
        quiteBtn.clicked.connect(self.close_application)

        addBtn = QtGui.QPushButton("Add", self)
        addBtn.resize(100, 50)
        addBtn.move(150,220)
        addBtn.clicked.connect(self.addNumbers)
        self.show()

    def addNumbers(self):
        print self.number_1_text
        print self.number_2_text
        print "Done"

    #Close The Whole Application
    def close_application(self):
        choice = QtGui.QMessageBox.question(self, 'Exit !', 'Are you sure you wanna exit?',
            QtGui.QMessageBox.Yes | QtGui.QMessageBox.No
            )
        if choice == QtGui.QMessageBox.Yes:
            sys.exit()
        else:
            pass
</code></pre>

<p>I tried to get the values with <code>text()</code> function and assigned it to a global variable in the class, then I tried to call the values in <code>addNumbers</code> function but I get an empty value.</p>

<p>A screenshot of the result:
<a href="https://i.stack.imgur.com/1LXda.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1LXda.png" alt="Result"></a></p>