from PyQt5.QtWidgets import(QApplication,QWidget,QPushButton,QLCDNumber,QFormLayout,QLineEdit,QLabel,QGridLayout)from PyQt5.QtGui importQFontfrom PyQt5.QtCore importQt,QTimer,QDateTime,QDate,QTime,QSizeimportsysclassExample(QWidget):def __init__(self):
super(Example, self).__init__()
self.initUI()definitUI(self):
self.setGeometry(300,300,330,310)
self.setWindowTitle("数字键盘输入")
gridLayout=QGridLayout()
self.display= QLineEdit("0")
self.display.setFixedSize(QSize(287,40))
self.display.setReadOnly(True)
self.display.setAlignment(Qt.AlignRight)
self.display.setFont(QFont("微软雅黑",14,QFont.Bold))
gridLayout.addWidget(self.display,0,0,1,4)
self.showNum= ""keys= [‘Clear‘, ‘/‘, ‘*‘, ‘-‘,‘7‘, ‘8‘, ‘9‘, ‘+‘,‘4‘, ‘5‘, ‘6‘, ‘‘,‘1‘, ‘2‘, ‘3‘, ‘Enter‘,‘0‘, ‘‘, ‘.‘, ‘‘]
position= [(0, 0), (0, 1), (0