I m developing GUI using PyQT4: Code looks like below -
def fileopening():
filename = QtGui.QFileDialog.getOpenFileName(mainwindow, 'Select file')
print(filename)
return filename
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
mainwindow = QtGui.QWidget()
ui = Ui_mainwindow()
ui.setupUi(mainwindow)
filename = ui.browser.clicked.connect(fileopening)
print(filename)
ui.progressBar.setValue(100)
ui.progesslabel.setText('Kindly fill in the fields and proceed for splitting.')
ui.splitbutton.clicked.connect(pressed)
ui.resetparameter.clicked.connect(reset)
mainwindow.show()
app.exec_()
When UI is prompted it gives print output as 'None' and from defination of function it gets filename in function call but it is not returning any value. Can anybody suggest what may be the possible reason? I want to pass 'Filename' as argument to other function call but always it is returning 'None' as value.
HAve you tried
return QtGui.QFileDialog.getOpenFileName(mainwindow, 'Select file')
You can make the name filename global.
def fileopening():
global filename
filename = QtGui.QFileDialog.getOpenFileName(mainwindow, 'Select file')