我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用PyQt5.QtWidgets.QLCDNumber()。
def init_ui(self): """Setup control widget UI.""" self.control_layout = QHBoxLayout() self.setLayout(self.control_layout) self.reset_button = QPushButton() self.reset_button.setFixedSize(40, 40) self.reset_button.setIcon(QtGui.QIcon(WIN_PATH)) self.game_timer = QLCDNumber() self.game_timer.setStyleSheet("QLCDNumber {color: red;}") self.game_timer.setFixedWidth(100) self.move_counter = QLCDNumber() self.move_counter.setStyleSheet("QLCDNumber {color: red;}") self.move_counter.setFixedWidth(100) self.control_layout.addWidget(self.game_timer) self.control_layout.addWidget(self.reset_button) self.control_layout.addWidget(self.move_counter)
def setupUi(self, Form): Form.setObjectName("Form") Form.resize(1053, 761) self.label = QtWidgets.QLabel(Form) self.label.setGeometry(QtCore.QRect(240, 20, 551, 171)) self.label.setObjectName("label") self.dial = QtWidgets.QDial(Form) self.dial.setGeometry(QtCore.QRect(670, 310, 131, 81)) self.dial.setObjectName("dial") self.layoutWidget = QtWidgets.QWidget(Form) self.layoutWidget.setGeometry(QtCore.QRect(240, 230, 194, 230)) self.layoutWidget.setObjectName("layoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("verticalLayout") self.label_2 = QtWidgets.QLabel(self.layoutWidget) self.label_2.setObjectName("label_2") self.verticalLayout.addWidget(self.label_2) self.label_3 = QtWidgets.QLabel(self.layoutWidget) self.label_3.setObjectName("label_3") self.verticalLayout.addWidget(self.label_3) self.label_4 = QtWidgets.QLabel(self.layoutWidget) self.label_4.setObjectName("label_4") self.verticalLayout.addWidget(self.label_4) self.layoutWidget1 = QtWidgets.QWidget(Form) self.layoutWidget1.setGeometry(QtCore.QRect(470, 230, 191, 231)) self.layoutWidget1.setObjectName("layoutWidget1") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.layoutWidget1) self.verticalLayout_2.setContentsMargins(0, 0, 0, 0) self.verticalLayout_2.setObjectName("verticalLayout_2") self.ledT = QtWidgets.QLCDNumber(self.layoutWidget1) self.ledT.setObjectName("ledT") self.verticalLayout_2.addWidget(self.ledT) self.ledE = QtWidgets.QLCDNumber(self.layoutWidget1) self.ledE.setObjectName("ledE") self.verticalLayout_2.addWidget(self.ledE) self.ledH = QtWidgets.QLCDNumber(self.layoutWidget1) self.ledH.setObjectName("ledH") self.verticalLayout_2.addWidget(self.ledH) self.retranslateUi(Form) self.dial.valueChanged['int'].connect(self.ledE.display) QtCore.QMetaObject.connectSlotsByName(Form)