def my_function(event=None):
    print('Button clicked: event:', event)
print(linetext.text())
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
vbox = QtGui.QVBoxLayout()
window.setLayout(vbox)
linetext = QtGui.QLineEdit(window)
vbox.addWidget(linetext)
button = QtGui.QPushButton('Run', window)
vbox.addWidget(button)
button.clicked.connect(my_function)
window.show()
sys.exit(app.exec_())
Use pyqt4 to create GUI that runs python script