简体   繁体   中英

Open a pop-up window after selecting files in QFileDialog - Python

I have a main window with upload button, after clicking the upload button a QFileDialog opens to upload the files. How can I enable a pop-up to appear after selecting the files and clicking open button in the upload dialog?

I tried this one but it closes the program

 def App(Qwidget, self):
    w = QWidget()
    w.resize(320, 240)
    QFileDialog.getOpenFileNames(w, 'Open File', '/')
    w.show()
    self.EWindow = QtWidgets.QWidget()
    self.ui = Ui_Form()
    self.ui.setupUi(self.EWindow)
    self.EWindow.show()

Using QPushButton clicked() event

button = QPushButton('Open', self)
button.clicked.connect(self.on_click)

calling QFileDialog and QMessageBox from QPushButton clicked() event

def on_click(self):
    fileName, _ = QFileDialog.getOpenFileName(self,"Open File", "","All Files (*);;Python Files (*.py)")
    if fileName:
        print(fileName)
    buttonReply = QMessageBox.question(self, 'Message Box', "Do you like PyQt5?", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
    if buttonReply == QMessageBox.Yes:
        print('Yes clicked.')
    else:
        print('No clicked.')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM