学习《PyQt4入门指南 PDF中文版.pdf 》笔记
文件对话框允许用户选择文件或者文件夹,被选择的文件可以进行读或写操作。
<span style="font-size:12px;">#!/usr/bin/python
# openfiledialog.py
from PyQt5.QtWidgets import QApplication, QAction, QFileDialog, QTextEdit
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QIcon
class OpenFile(QtWidgets.QMainWindow):
def __init__(self, parent= None):
QtWidgets.QWidget.__init__(self)
self.setGeometry(300, 300, 150, 110)
self.setWindowTitle('OpenFile')
self.textEdit = QTextEdit()
self.setCentralWidget(self.textEdit)
self.statusBar()
self.setFocus()
exit = QAction(QIcon('icons/Blue_Flower.ico'), 'Open', self)
exit.setShortcut('Ctrl+O')
exit.setStatusTip('Open