pyqt5 file dialog example

Solutions on MaxInterview for pyqt5 file dialog example by the best coders in the world

showing results for - "pyqt5 file dialog example"
Andrea
08 Nov 2016
1import sys
2from PyQt5.QtWidgets import QApplication, QMainWindow, QWidget, \
3    QPushButton, QVBoxLayout, QFileDialog
4
5# you can copy and run this code
6
7class MainWindow(QMainWindow):
8    def __init__(self, parent=None):#--------------
9        super(MainWindow, self).__init__(parent)#  |
10        self.setWindowTitle("open file dialog")#   |
11#												   |
12        btn = QPushButton("Open File")#            |---- Just initialization
13        layout = QVBoxLayout()#					   |
14        layout.addWidget(btn)#                     |
15        widget = QWidget()#                        |
16        widget.setLayout(layout)#                  |
17        self.setCentralWidget(widget)#-------------
18
19        btn.clicked.connect(self.open) # connect clicked to self.open()
20        self.show()
21
22    def open(self):
23        path = QFileDialog.getOpenFileName(self, 'Open a file', '',
24                                        'All Files (*.*)')
25        if path != ('', ''):
26            print("File path : "+ path[0])
27
28if __name__ == "__main__":
29    app = QApplication(sys.argv)
30    window = MainWindow()
31    sys.exit(app.exec_())
Alessio
03 Jun 2016
1def open_file(self):
2	def open(self):
3        path = QFileDialog.getOpenFileName(self, 'Open a file', '',
4                                        'All Files (*.*)')
5        if path != ('', ''):
6            print(path[0])
Aidan
02 Sep 2017
1def open(self):
2    path = QFileDialog.getOpenFileName(self, 'Open a file', '',
3                                     'All Files (*.*)')
4    if path != ('', ''):
5		print(path[0])
queries leading to this page
file dialog in pyqt5show dialog pyqt5pyqt file dialog finished 28 29qfiledialog pyqthow to open a file dialog in askopenfilename pyqt5 pythonpyqt5 input dialog examplesfile dialog pyqt5pyqt file dialog folderpyqt5 open file dialog buttonwhat is ui dialog in pyqt5pyqt save dialog with openfile open dialog in pyqt5pyqt5 save dialogpyqt browse filedialog cloud in pyqt5file input pyqt5pyqt dialog examplepyqt5 dialogopening dialog pyqt5pyqt5 lunch dialogpyqt5 python create a dialog customfiledialog python pyqt5pyqt file dialog imagepyqt5 new dialogpyqt5 dialogspyqt5 new dialog typespyqt5 browse file dialogopen file dialog pyqt5pyqt5 dialogopen dialog pyqt5 on button clickpyqt5 dialog windowpyqt5 open dialog from mainwindowpython pyqt file dialogpyqt5 open file dialogpython pyqt file dialog savepython qt qfiledialog getopenfilenamepyqt5 dialog box examplepyqt5 file dialog directoryfile open in pyqt5open file dialog on button click pyqt5pyqt5 dialog boxqwidget pyqt5 python name of filedialog open file pyqt5pyqt5 open file dialougepyqt file dialog save with openpyqt5 settings dialogfile explorer pyqtpyqt5 browseslot file dialoghow to make a dialog box in pyqt5pyqt save dialogpython open file dialog pyqt5pyqt file searchpyqt5 file dialogoppen file pyqtinput dialog in pyqt5dialog button box pyqt5pyqt5 file dialog pythonpyqt open file dialog examplehow to add open file dialog in pyqt5 on button pressopen file dialog pyqt6pyqt5 dialog box with widgetspyqt open file dialogpyqt dialogopen file pyqt5qfiledialog getopenfilename pythonopen file pyqtpython qfiledialog getopenfilenamepyqt5 file open dialogpython import file dialog pyqtfile explorer pyqt5pyqt5 save file dialogget file options pyqt5python pyqt5 dialog boxfile dialog box in pyqt5file file dialog for audio pyqt5open file manager python pyqt5file selector in pyqt5how to create a dialog window in pyqt5pyqt save dialog with open writepyqt save file dialogopenfile pyqtqfiledialog pyqt5pyqt5 5 save dialoghow to open dialog box in pyqt5pyqt6 open new file dialogfiledialog in pyqt5pyqt5 open window to save dialogfile dialog in pyqt5 designer 3fpyqt5 dialog button boxpyqt5 file path dialogpyqt5 upload filehow to make choose file dialog in pyqt5how to open file browser in python with pyqt5pyqt5 choose filepyqt5 dialogue pyqt file dialogpyqt qfiledialog examplepyqt5 file dialog examplepyqt5 create dialogopen file manager pyqt5 designerqfiledialog widget exampledialog pyqt5set pqt file save dialog example pythonon button click show open file dialog and selet file in python pyqt5pyqt5 input dialogpyqt5 dialog windows shows 3fqfiledialog example pythonopen file manager python pyqt5 designeropen file dialog box in pyqt5pyqt5 file dialog example