Reputation: 809
I have written a python script that manipulates data and then saves it into an excel file with the following function:
def saveData():
table = pd.DataFrame(data)
writer = pd.ExcelWriter('manipulatedData.xlsx')
table.to_excel(writer, 'sheet 1')
writer.save()
I also have the following super basic/minimalistic gui window:
from PyQt4 import QtGui
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
window.setGeometry(500,500,500,500)
window.setWindowTitle("PyQt Test!")
window.setWindowIcon(QtGui.QIcon('pythonLogoSmall.png'))
window.show()
sys.exit(app.exec_())
What I really would like to know is this:
1) How can I let the user of my gui select the location + name for the manipulatedData file?
2) How can I add a "run" button, that starts my python script and manipulates the data, before it saves the manipulated data to the desired location.
Upvotes: 3
Views: 943
Reputation: 142631
PyQt4
has QLineEdit()
and QPushButton()
from PyQt4 import QtGui
import sys
# --- functions ---
def my_function(event=None):
print 'Button clicked: event:', event
print linetext.text()
# run your code
# --- main ---
app = QtGui.QApplication(sys.argv)
window = QtGui.QWidget()
# add "layout manager"
vbox = QtGui.QVBoxLayout()
window.setLayout(vbox)
# add place for text
linetext = QtGui.QLineEdit(window)
vbox.addWidget(linetext)
# add button
button = QtGui.QPushButton("Run", window)
vbox.addWidget(button)
# add function to button
button.clicked.connect(my_function)
window.show()
sys.exit(app.exec_())
Upvotes: 1