from PyQt5.QtWidgets import *
from PyQt5.QtGui import QFont
import sys
class PyQt502(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
self.setWindowTitle(' 气轻PyQt5') # 设置窗口标题
self.resize(700, 300) # 设置窗口大小
self.edit = QLineEdit(self) # 输入框
self.edit.setGeometry(10, 0,240, 40) # 设置位置和大小
self.edit.setText('edit')
self.edit.setFont(QFont('Arial',20))
self.edit.setReadOnly(True) # 只读
self.edit.setStyleSheet("background-color:rgba(0,200,255,255)")
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = PyQt502()
sys.exit(app.exec_())
执行结果