import sys
import os
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
class Notepad(QMainWindow):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
openAction = QAction('Open', self)
openAction.setShortcut('Ctrl+O')
openAction.setStatusTip('Open a file')
openAction.triggered.connect(self.openFile)
closeAction = QAction('Close', self)
closeAction.setShortcut('Ctrl+Q')
closeAction.setStatusTip('Close Notepad')
closeAction.triggered.connect(self.close)
menubar = self.menuBar()
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(openAction)
fileMenu.addAction(closeAction)
self.textEdit = QTextEdit(self)
self.textEdit.setFocus()
self.textEdit.setReadOnly(True)
self.resize(700, 800)
pyqt5 打开文件
最新推荐文章于 2024-07-23 00:07:27 发布