I want to create 2 upload file button in PyQt. One for image and one for .csv file. If the uploaded file is not in image or .csv file it should thrown an message.
I have search a lot on internet and in internet but couldn't find answer.
If the uploaded file is not in image or .csv file it should thrown an message.
It is not the most common approach I think.
The best way to do this is to create a file dialog, that allows to choose only one extension. Example:
def upload_csv(self): dialog = QtGui.QFileDialog() fname = dialog.getOpenFileName(None, "Import CSV", "", "CSV data files (*.csv)")
Then just connect this function to any button you want. File dialog appears each time you click on it and you can choose only csv file. You can combine more extensions in one dialog if you want.