3

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.

0

1 Answer 1

1

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_())
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.