繁体   English   中英

在QFileDialog中选择文件后,打开一个弹出窗口-Python

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

我有一个带有上载按钮的主窗口,单击上载按钮后,将打开QFileDialog来上载文件。 选择文件并单击上载对话框中的打开按钮后,如何使弹出窗口出现?

我尝试了这个,但是它关闭了程序

 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()

使用QPushButton clicked()事件

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

从QPushButton clicked()事件调用QFileDialog和QMessageBox

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.')

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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