Yes, it is possible. I suggest using the
QFileDialog.getOpenFileName()
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QFileDialog
class MainWin(QMainWindow):
def __init__(self):
super().__init__()
self.setGeometry(150,150,200,150)
self.setWindowTitle("Test")
button = QPushButton('Open with', self)
button.clicked.connect(self.dialog)
button.resize(100,32)
button.move(50,50)
self.show()
def dialog(self):
# https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QFileDialog.html#PySide2.QtWidgets.PySide2.QtWidgets.QFileDialog.getOpenFileName
file, check = QFileDialog.getOpenFileName(
None,
"QFileDialog.getOpenFileName()",
"",
self.tr(
'All Files (*);;'
'Python Files (*.py);;'
'Text Files (*.txt)'))
if check:
print(file)
if __name__ == "__main__":
app = QApplication(sys.argv)
win = MainWin()
sys.exit( app.exec_() )