pyqt5通过文本对话框打开文件

点击按钮,打开文本对话框,找一人文件,打开并显示内容                                                                                                                                                                                     

                                                                                                                                                                                              QFIleDialog

技术分享                                                                 技术分享

def openfile(self):
    filename,_ = QFileDialog.getOpenFileName(self);
    text=open(filename,r).read()
    self.textEdit.setText(text)

我用QFile,QTextStream,QIODevice做了半天也没做出来,改用python自带的文件操作命令做了出来。

文章来自:http://www.cnblogs.com/jmlovepython/p/5728679.html
© 2021 jiaocheng.bubufx.com  联系我们
ICP备案:鲁ICP备09046678号-3