求大佬指点
#主程序
import sys
from PySide2.QtWidgets import *
from PySide2.QtCore import *
from PySide2.QtGui import *
from ui_mainwindow import Ui_MainWindow
class DianJi(QMainWindow, Ui_MainWindow):
def __init__(self):
super().__init__()
self.setupUi(self)
self.show()
def setup(self):
self.l = 0
self.r = 0
self.pbtn_L1.clicked.connect(self.pbtn_1)
self.pbtn_R1.clicked.connect(self.pbtn_2)
self.pbtn_L2.clicked.connect(self.pbtn_3)
self.pbtn_R2.clicked.connect(self.pbtn_4)
def pbtn_1(self):
self.l += 1
self.lb_L.setText(self.l)
def pbtn_2(self):
self.r += 1
self.lb_R.setText(self.r)
def pbtn_1(self):
self.l -= 1
self.lb_L.setText(self.l)
def pbtn_2(self):
self.r -= 1
self.lb_R.setText(self.r)
if __name__ == '__main__':
app = QApplication(sys.argv)
window = DianJi()
sys.exit(app.exec_())
#ui_mainwindow
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'mainwindow.ui'
##
## Created by: Qt User Interface Compiler version 5.15.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide2.QtCore import *
from PySide2.QtGui import *
from PySide2.QtWidgets import *
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(800, 600)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.lb_L = QLabel(self.centralwidget)
self.lb_L.setObjectName(u"lb_L")
self.lb_L.setGeometry(QRect(60, 50, 211, 491))
font = QFont()
font.setPointSize(70)
self.lb_L.setFont(font)
self.lb_L.setAlignment(Qt.AlignCenter)
self.lb_R = QLabel(self.centralwidget)
self.lb_R.setObjectName(u"lb_R")
self.lb_R.setGeometry(QRect(530, 50, 211, 491))
self.lb_R.setFont(font)
self.lb_R.setAlignment(Qt.AlignCenter)
self.pbtn_L1 = QPushButton(self.centralwidget)
self.pbtn_L1.setObjectName(u"pbtn_L1")
self.pbtn_L1.setGeometry(QRect(140, 50, 51, 51))
font1 = QFont()
font1.setPointSize(40)
font1.setBold(True)
font1.setWeight(75)
self.pbtn_L1.setFont(font1)
self.pbtn_R1 = QPushButton(self.centralwidget)
self.pbtn_R1.setObjectName(u"pbtn_R1")
self.pbtn_R1.setGeometry(QRect(610, 50, 51, 51))
self.pbtn_R1.setFont(font1)
self.pbtn_L2 = QPushButton(self.centralwidget)
self.pbtn_L2.setObjectName(u"pbtn_L2")
self.pbtn_L2.setGeometry(QRect(140, 490, 51, 51))
self.pbtn_L2.setFont(font1)
self.pbtn_R2 = QPushButton(self.centralwidget)
self.pbtn_R2.setObjectName(u"pbtn_R2")
self.pbtn_R2.setGeometry(QRect(610, 490, 51, 51))
self.pbtn_R2.setFont(font1)
MainWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"dianji", None))
self.lb_L.setText(QCoreApplication.translate("MainWindow", u"0", None))
self.lb_R.setText(QCoreApplication.translate("MainWindow", u"0", None))
self.pbtn_L1.setText(QCoreApplication.translate("MainWindow", u"+", None))
self.pbtn_R1.setText(QCoreApplication.translate("MainWindow", u"+", None))
self.pbtn_L2.setText(QCoreApplication.translate("MainWindow", u"-", None))
self.pbtn_R2.setText(QCoreApplication.translate("MainWindow", u"-", None))
# retranslateUi