PyQt5 示例(二)

有的地方有问题,解决的时候话了点时间,记录下,方便以后查找

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'scoreboard.ui'
#
# Created by: PyQt5 UI code generator 5.11.3
#
# WARNING! All changes made in this file will be lost!

from PyQt5 import QtCore, QtGui, QtWidgets
import sys


class Ui_MainWindow(object):

    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(555, 405)
        MainWindow.setWindowFlags(QtCore.Qt.WindowCloseButtonHint)
        MainWindow.setFixedSize(MainWindow.width(), MainWindow.height())
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget.setGeometry(QtCore.QRect(30, 20, 111, 31))
        self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget)
        self.horizontalLayout.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.checkBox_1 = QtWidgets.QCheckBox(self.horizontalLayoutWidget)
        self.checkBox_1.setObjectName("checkBox_1")
        self.horizontalLayout.addWidget(self.checkBox_1)
        self.kill_chuan = QtWidgets.QSpinBox(self.horizontalLayoutWidget)
        self.kill_chuan.setObjectName("kill_chuan")
        self.kill_chuan.setMinimum(-20)
        self.horizontalLayout.addWidget(self.kill_chuan)
        self.textBrowser = QtWidgets.QTextBrowser(self.centralwidget)
        self.textBrowser.setGeometry(QtCore.QRect(20, 120, 271, 181))
        self.textBrowser.setObjectName("textBrowser")
        self.horizontalLayoutWidget_9 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_9.setGeometry(QtCore.QRect(310, 120, 108, 31))
        self.horizontalLayoutWidget_9.setObjectName("horizontalLayoutWidget_9")
        self.horizontalLayout_9 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_9)
        self.horizontalLayout_9.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_9.setObjectName("horizontalLayout_9")
        self.label = QtWidgets.QLabel(self.horizontalLayoutWidget_9)
        self.label.setObjectName("label")
        self.horizontalLayout_9.addWidget(self.label)
        self.lcd_chuan = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_9)
        self.lcd_chuan.setObjectName("lcd_chuan")
        self.horizontalLayout_9.addWidget(self.lcd_chuan)
        self.horizontalLayoutWidget_10 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_10.setGeometry(QtCore.QRect(310, 170, 108, 31))
        self.horizontalLayoutWidget_10.setObjectName("horizontalLayoutWidget_10")
        self.horizontalLayout_10 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_10)
        self.horizontalLayout_10.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_10.setObjectName("horizontalLayout_10")
        self.label_2 = QtWidgets.QLabel(self.horizontalLayoutWidget_10)
        self.label_2.setObjectName("label_2")
        self.horizontalLayout_10.addWidget(self.label_2)
        self.lcd_feng = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_10)
        self.lcd_feng.setObjectName("lcd_feng")
        self.horizontalLayout_10.addWidget(self.lcd_feng)
        self.horizontalLayoutWidget_11 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_11.setGeometry(QtCore.QRect(310, 220, 108, 31))
        self.horizontalLayoutWidget_11.setObjectName("horizontalLayoutWidget_11")
        self.horizontalLayout_11 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_11)
        self.horizontalLayout_11.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_11.setObjectName("horizontalLayout_11")
        self.label_3 = QtWidgets.QLabel(self.horizontalLayoutWidget_11)
        self.label_3.setObjectName("label_3")
        self.horizontalLayout_11.addWidget(self.label_3)
        self.lcd_long = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_11)
        self.lcd_long.setObjectName("lcd_long")
        self.horizontalLayout_11.addWidget(self.lcd_long)
        self.horizontalLayoutWidget_12 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_12.setGeometry(QtCore.QRect(310, 270, 108, 31))
        self.horizontalLayoutWidget_12.setObjectName("horizontalLayoutWidget_12")
        self.horizontalLayout_12 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_12)
        self.horizontalLayout_12.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_12.setObjectName("horizontalLayout_12")
        self.label_4 = QtWidgets.QLabel(self.horizontalLayoutWidget_12)
        self.label_4.setObjectName("label_4")
        self.horizontalLayout_12.addWidget(self.label_4)
        self.lcd_gou = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_12)
        self.lcd_gou.setObjectName("lcd_gou")
        self.horizontalLayout_12.addWidget(self.lcd_gou)
        self.horizontalLayoutWidget_13 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_13.setGeometry(QtCore.QRect(430, 170, 108, 31))
        self.horizontalLayoutWidget_13.setObjectName("horizontalLayoutWidget_13")
        self.horizontalLayout_17 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_13)
        self.horizontalLayout_17.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_17.setObjectName("horizontalLayout_17")
        self.label_17 = QtWidgets.QLabel(self.horizontalLayoutWidget_13)
        self.label_17.setObjectName("label_17")
        self.horizontalLayout_17.addWidget(self.label_17)
        self.lcd_ji = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_13)
        self.lcd_ji.setObjectName("lcd_ji")
        self.horizontalLayout_17.addWidget(self.lcd_ji)
        self.horizontalLayoutWidget_14 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_14.setGeometry(QtCore.QRect(430, 120, 108, 31))
        self.horizontalLayoutWidget_14.setObjectName("horizontalLayoutWidget_14")
        self.horizontalLayout_18 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_14)
        self.horizontalLayout_18.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_18.setObjectName("horizontalLayout_18")
        self.label_18 = QtWidgets.QLabel(self.horizontalLayoutWidget_14)
        self.label_18.setObjectName("label_18")
        self.horizontalLayout_18.addWidget(self.label_18)
        self.lcd_mu = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_14)
        self.lcd_mu.setObjectName("lcd_mu")
        self.horizontalLayout_18.addWidget(self.lcd_mu)
        self.horizontalLayoutWidget_15 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_15.setGeometry(QtCore.QRect(430, 270, 108, 31))
        self.horizontalLayoutWidget_15.setObjectName("horizontalLayoutWidget_15")
        self.horizontalLayout_19 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_15)
        self.horizontalLayout_19.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_19.setObjectName("horizontalLayout_19")
        self.label_19 = QtWidgets.QLabel(self.horizontalLayoutWidget_15)
        self.label_19.setObjectName("label_19")
        self.horizontalLayout_19.addWidget(self.label_19)
        self.lcd_hao = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_15)
        self.lcd_hao.setObjectName("lcd_hao")
        self.horizontalLayout_19.addWidget(self.lcd_hao)
        self.horizontalLayoutWidget_16 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_16.setGeometry(QtCore.QRect(430, 220, 108, 31))
        self.horizontalLayoutWidget_16.setObjectName("horizontalLayoutWidget_16")
        self.horizontalLayout_20 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_16)
        self.horizontalLayout_20.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_20.setObjectName("horizontalLayout_20")
        self.label_20 = QtWidgets.QLabel(self.horizontalLayoutWidget_16)
        self.label_20.setObjectName("label_20")
        self.horizontalLayout_20.addWidget(self.label_20)
        self.lcd_ge = QtWidgets.QLCDNumber(self.horizontalLayoutWidget_16)
        self.lcd_ge.setObjectName("lcd_ge")
        self.horizontalLayout_20.addWidget(self.lcd_ge)
        self.chiken_done = QtWidgets.QCheckBox(self.centralwidget)
        self.chiken_done.setGeometry(QtCore.QRect(370, 330, 51, 31))
        self.chiken_done.setObjectName("chiken_done")
        # self.not_chhiken = QtWidgets.QRadioButton(self.centralwidget)
        # self.not_chhiken.setGeometry(QtCore.QRect(370, 360, 51, 16))
        # self.not_chhiken.setObjectName("not_chhiken")
        self.pushButton = QtWidgets.QPushButton(self.centralwidget)
        self.pushButton.setGeometry(QtCore.QRect(450, 330, 71, 31))
        self.pushButton.setObjectName("pushButton")
        self.result_text = QtWidgets.QLineEdit(self.centralwidget)
        self.result_text.setGeometry(QtCore.QRect(20, 330, 331, 31))
        self.result_text.setText("")
        self.result_text.setObjectName("result_text")
        self.horizontalLayoutWidget_2 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_2.setGeometry(QtCore.QRect(160, 20, 111, 31))
        self.horizontalLayoutWidget_2.setObjectName("horizontalLayoutWidget_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_2)
        self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.checkBox_2 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_2)
        self.checkBox_2.setObjectName("checkBox_2")
        self.horizontalLayout_2.addWidget(self.checkBox_2)
        self.kill_feng = QtWidgets.QSpinBox(self.horizontalLayoutWidget_2)
        self.kill_feng.setObjectName("kill_feng")
        self.kill_feng.setMinimum(-20)
        self.horizontalLayout_2.addWidget(self.kill_feng)
        self.horizontalLayoutWidget_3 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_3.setGeometry(QtCore.QRect(300, 20, 111, 31))
        self.horizontalLayoutWidget_3.setObjectName("horizontalLayoutWidget_3")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_3)
        self.horizontalLayout_3.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.checkBox_3 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_3)
        self.checkBox_3.setObjectName("checkBox_3")
        self.horizontalLayout_3.addWidget(self.checkBox_3)
        self.kill_long = QtWidgets.QSpinBox(self.horizontalLayoutWidget_3)
        self.kill_long.setObjectName("kill_long")
        self.kill_long.setMinimum(-20)
        self.horizontalLayout_3.addWidget(self.kill_long)
        self.horizontalLayoutWidget_4 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_4.setGeometry(QtCore.QRect(430, 20, 111, 31))
        self.horizontalLayoutWidget_4.setObjectName("horizontalLayoutWidget_4")
        self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_4)
        self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_4.setObjectName("horizontalLayout_4")
        self.checkBox_4 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_4)
        self.checkBox_4.setObjectName("checkBox_4")
        self.horizontalLayout_4.addWidget(self.checkBox_4)
        self.kill_gou = QtWidgets.QSpinBox(self.horizontalLayoutWidget_4)
        self.kill_gou.setObjectName("kill_gou")
        self.kill_gou.setMinimum(-20)
        self.horizontalLayout_4.addWidget(self.kill_gou)
        self.horizontalLayoutWidget_5 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_5.setGeometry(QtCore.QRect(430, 70, 111, 31))
        self.horizontalLayoutWidget_5.setObjectName("horizontalLayoutWidget_5")
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_5)
        self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.checkBox_8 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_5)
        self.checkBox_8.setObjectName("checkBox_8")
        self.horizontalLayout_5.addWidget(self.checkBox_8)
        self.kill_hao = QtWidgets.QSpinBox(self.horizontalLayoutWidget_5)
        self.kill_hao.setObjectName("kill_hao")
        self.kill_hao.setMinimum(-20)
        self.horizontalLayout_5.addWidget(self.kill_hao)
        self.horizontalLayoutWidget_6 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_6.setGeometry(QtCore.QRect(30, 70, 111, 31))
        self.horizontalLayoutWidget_6.setObjectName("horizontalLayoutWidget_6")
        self.horizontalLayout_6 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_6)
        self.horizontalLayout_6.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_6.setObjectName("horizontalLayout_6")
        self.checkBox_5 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_6)
        self.checkBox_5.setObjectName("checkBox_5")
        self.horizontalLayout_6.addWidget(self.checkBox_5)
        self.kill_mu = QtWidgets.QSpinBox(self.horizontalLayoutWidget_6)
        self.kill_mu.setObjectName("kill_mu")
        self.kill_mu.setMinimum(-20)
        self.horizontalLayout_6.addWidget(self.kill_mu)
        self.horizontalLayoutWidget_7 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_7.setGeometry(QtCore.QRect(160, 70, 111, 31))
        self.horizontalLayoutWidget_7.setObjectName("horizontalLayoutWidget_7")
        self.horizontalLayout_7 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_7)
        self.horizontalLayout_7.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_7.setObjectName("horizontalLayout_7")
        self.checkBox_6 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_7)
        self.checkBox_6.setObjectName("checkBox_6")
        self.horizontalLayout_7.addWidget(self.checkBox_6)
        self.kill_ge = QtWidgets.QSpinBox(self.horizontalLayoutWidget_7)
        self.kill_ge.setObjectName("kill_ge")
        self.kill_ge.setMinimum(-20)
        self.horizontalLayout_7.addWidget(self.kill_ge)
        self.horizontalLayoutWidget_8 = QtWidgets.QWidget(self.centralwidget)
        self.horizontalLayoutWidget_8.setGeometry(QtCore.QRect(300, 70, 111, 31))
        self.horizontalLayoutWidget_8.setObjectName("horizontalLayoutWidget_8")
        self.horizontalLayout_8 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget_8)
        self.horizontalLayout_8.setContentsMargins(0, 0, 0, 0)
        self.horizontalLayout_8.setObjectName("horizontalLayout_8")
        self.checkBox_7 = QtWidgets.QCheckBox(self.horizontalLayoutWidget_8)
        self.checkBox_7.setObjectName("checkBox_7")
        self.horizontalLayout_8.addWidget(self.checkBox_7)
        self.kill_ji = QtWidgets.QSpinBox(self.horizontalLayoutWidget_8)
        self.kill_ji.setObjectName("kill_ji")
        self.kill_ji.setMinimum(-20)
        self.horizontalLayout_8.addWidget(self.kill_ji)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menuBar = QtWidgets.QMenuBar(MainWindow)
        self.menuBar.setGeometry(QtCore.QRect(0, 0, 555, 23))
        self.menuBar.setObjectName("menuBar")
        self.menu_main = QtWidgets.QMenu(self.menuBar)
        self.menu_main.setObjectName("menu_main")
        MainWindow.setMenuBar(self.menuBar)
        # self.action_cancel = QtWidgets.QAction(MainWindow)
        # self.action_cancel.setObjectName("action_cancel")
        self.actionsdf = QtWidgets.QAction(MainWindow)
        self.actionsdf.setObjectName("actionsdf")
        # self.menu_main.addAction(self.action_cancel)
        # self.menu_main.addSeparator()
        self.menu_main.addAction(self.actionsdf)
        self.menuBar.addAction(self.menu_main.menuAction())

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "吃鸡记分板"))
        self.checkBox_1.setText(_translate("MainWindow", " 川"))
        self.textBrowser.setHtml(_translate("MainWindow",
                                            "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
                                            "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
                                            "p, li { white-space: pre-wrap; }\n"
                                            "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
                                            "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>"))
        self.label.setText(_translate("MainWindow", "  川:"))
        self.label_2.setText(_translate("MainWindow", "  枫:"))
        self.label_3.setText(_translate("MainWindow", "  龙:"))
        self.label_4.setText(_translate("MainWindow", "  狗:"))
        self.label_17.setText(_translate("MainWindow", "  鸡:"))
        self.label_18.setText(_translate("MainWindow", "  木:"))
        self.label_19.setText(_translate("MainWindow", "  豪:"))
        self.label_20.setText(_translate("MainWindow", "  鸽:"))
        self.chiken_done.setText(_translate("MainWindow", "吃鸡"))
        # self.not_chhiken.setText(_translate("MainWindow", "吃屎"))
        self.pushButton.setText(_translate("MainWindow", "计算"))
        self.checkBox_2.setText(_translate("MainWindow", " 枫"))
        self.checkBox_3.setText(_translate("MainWindow", " 龙"))
        self.checkBox_4.setText(_translate("MainWindow", " 狗"))
        self.checkBox_8.setText(_translate("MainWindow", " 豪"))
        self.checkBox_5.setText(_translate("MainWindow", " 木"))
        self.checkBox_6.setText(_translate("MainWindow", " 鸽"))
        self.checkBox_7.setText(_translate("MainWindow", " 鸡"))
        self.menu_main.setTitle(_translate("MainWindow", "重置"))
        # self.action_cancel.setText(_translate("MainWindow", "撤销上一步"))
        self.actionsdf.setText(_translate("MainWindow", "重置数据"))

    def get_player(self):
        player = []
        for i in range(1, 9):
            check_box = getattr(self, 'checkBox_%d' % i)
            if check_box.isChecked():
                player.append(i)
        return player

    def check_player(self):
        player = self.get_player()
        player_num = len(player)
        if player_num == 0:
            QtWidgets.QMessageBox.information(
                self,
                '错误',
                '请勾选吃鸡小队',
                QtWidgets.QMessageBox.Yes
            )
        elif player_num == 1:
            QtWidgets.QMessageBox.information(
                self,
                '错误',
                '一个人吃什么鸡',
                QtWidgets.QMessageBox.Yes
            )
        elif player_num > 4:
            QtWidgets.QMessageBox.information(
                self,
                '错误',
                '人太多了',
                QtWidgets.QMessageBox.Yes
            )
        player_dict_list = {
            '1': 'chuan',
            '2': 'feng',
            '3': 'long',
            '4': 'gou',
            '5': 'mu',
            '6': 'ge',
            '7': 'ji',
            '8': 'hao',
        }
        player_name = []
        for player_id in player:
            player_name.append(player_dict_list[str(player_id)])
        return player_name

    def get_kill_info(self):
        kill_info_dict = {}
        player_name_list = self.check_player()

        for player_name in player_name_list:
            kill_num_box = getattr(self, 'kill_%s' % player_name)
            kill_num = kill_num_box.value()
            kill_info_dict[player_name] = kill_num

        return kill_info_dict

    # 一个人分最低
    def one_lost(self, sort_list, kill_info):
        score = {}

        if len(sort_list) == 4:
            score[sort_list[3]] = kill_info[sort_list[3]] - kill_info[sort_list[0]]
            score[sort_list[2]] = kill_info[sort_list[2]] - kill_info[sort_list[0]]
            score[sort_list[1]] = kill_info[sort_list[1]] - kill_info[sort_list[0]]
            score[sort_list[0]] = -(score[sort_list[3]] + score[sort_list[2]] + score[sort_list[1]])
        elif len(sort_list) == 3:
            score[sort_list[2]] = kill_info[sort_list[2]] - kill_info[sort_list[0]]
            score[sort_list[1]] = kill_info[sort_list[1]] - kill_info[sort_list[0]]
            score[sort_list[0]] = -(score[sort_list[2]] + score[sort_list[1]])
        elif len(sort_list) == 2:
            score[sort_list[1]] = kill_info[sort_list[1]] - kill_info[sort_list[0]]
            score[sort_list[0]] = -(score[sort_list[1]])

        return score

    # 2个人分最低
    def two_lost(self, sort_list, kill_info):
        score = {}
        if len(sort_list) == 4:
            score[sort_list[3]] = 2*(kill_info[sort_list[3]] - kill_info[sort_list[0]])
            score[sort_list[2]] = 2*(kill_info[sort_list[2]] - kill_info[sort_list[0]])
            score[sort_list[1]] = score[sort_list[0]] = -(score[sort_list[3]] + score[sort_list[2]])/2

        elif len(sort_list) == 3:
            score[sort_list[2]] = 2*(kill_info[sort_list[2]] - kill_info[sort_list[0]])
            score[sort_list[1]] = score[sort_list[0]] = -(score[sort_list[2]])/2
        return score

    # 一吃三
    def three_lost(self, sort_list, kill_info):
        score = {}
        if len(sort_list) == 4:
            score[sort_list[3]] = 3*(kill_info[sort_list[3]] - kill_info[sort_list[0]])
            score[sort_list[2]] = score[sort_list[1]] = score[sort_list[0]] = -(score[sort_list[3]])/3
        return score

    def calculate(self):
        score_info = {}
        kill_info_dict = self.get_kill_info()
        sort_result = [k for k, v in sorted(kill_info_dict.items(), key=lambda item: item[1])]
        person_num = len(sort_result)
        if person_num == 4:
            if kill_info_dict[sort_result[0]] < kill_info_dict[sort_result[1]]:
                # 第一个杀人数最少  三 吃 1
                score_info = self.one_lost(sort_result, kill_info_dict)

            else:  # 第一 第二杀人数相等
                if kill_info_dict[sort_result[1]] < kill_info_dict[sort_result[2]]:
                    # 2吃2
                    score_info = self.two_lost(sort_result, kill_info_dict)

                else:
                    if kill_info_dict[sort_result[2]] < kill_info_dict[sort_result[3]]:
                        # 三吃
                        score_info = self.three_lost(sort_result, kill_info_dict)

                    else:
                        # 白打
                        QtWidgets.QMessageBox.information(
                            self,
                            '哈哈哈',
                            '恭喜你们,白打一句',
                            QtWidgets.QMessageBox.Yes
                        )
        elif person_num == 3:
            if kill_info_dict[sort_result[0]] < kill_info_dict[sort_result[1]]:
                # 第一个杀人数最少  2 吃 1
                score_info = self.one_lost(sort_result, kill_info_dict)

            else:  # 第一 第二杀人数相等
                if kill_info_dict[sort_result[1]] < kill_info_dict[sort_result[2]]:
                    # 2吃1
                    score_info = self.two_lost(sort_result, kill_info_dict)

                else:
                    # 白打
                    QtWidgets.QMessageBox.information(
                        self,
                        '哈哈哈',
                        '恭喜你们,白打一句',
                        QtWidgets.QMessageBox.Yes
                    )
            pass
        elif person_num == 2:
            if kill_info_dict[sort_result[0]] < kill_info_dict[sort_result[1]]:

                score_info = self.one_lost(sort_result, kill_info_dict)

            else:
                # 白打
                QtWidgets.QMessageBox.information(
                    self,
                    '哈哈哈',
                    '恭喜你们,白打一句',
                    QtWidgets.QMessageBox.Yes
                )
        return score_info

    def is_chicken(self):
        return self.chiken_done.isChecked()

    def show_result(self):
        m = 1
        name_dict = {
            'chuan': '川',
            'feng': '枫',
            'long': '龙',
            'gou': '狗',
            'mu': '木',
            'ge': '鸽',
            'ji': '鸡',
            'hao': '豪',
        }
        text_str = '【记分板】'
        kill_info_dict = self.get_kill_info()
        kill_str = '【击杀】'
        for k_name, v_num in kill_info_dict.items():
            kill_str += name_dict[k_name] + ': ' + str(int(v_num)) + '  '
        # 吃鸡double
        if self.is_chicken():
            m = 2
        score_info = self.calculate()
        for k, v in score_info.items():
            lcd = getattr(self, 'lcd_%s' % k)
            old_score = lcd.intValue()
            new_score = old_score + v*m
            text_str += name_dict[k] + ': ' + str(int(new_score)) + '分 '
            lcd.display(new_score)
        self.chiken_done.setChecked(False)
        play_name_list = self.check_player()
        for play_name in play_name_list:
            kill_num_box = getattr(self, 'kill_%s' % play_name)
            kill_num_box.setValue(0)

        self.result_text.setText(text_str)
        self.textBrowser.insertHtml(kill_str + '<br>')
        self.textBrowser.insertHtml(text_str + '<br>')

    def button_click(self):
        self.pushButton.clicked.connect(self.show_result)

    def reset_all(self):
        player_dict_list = {
            '1': 'chuan',
            '2': 'feng',
            '3': 'long',
            '4': 'gou',
            '5': 'mu',
            '6': 'ge',
            '7': 'ji',
            '8': 'hao',
        }

        for i in range(1, 9):
            check_box = getattr(self, 'checkBox_%d' % i)
            name = player_dict_list[str(i)]
            kill_num_box = getattr(self, 'kill_%s' % name)
            lcd_num = getattr(self, 'lcd_%s' % name)
            kill_num_box.setValue(0)
            lcd_num.display(0)
            check_box.setChecked(False)
        self.result_text.setText("")
        self.textBrowser.setHtml("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
                                            "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
                                            "p, li { white-space: pre-wrap; }\n"
                                            "</style></head><body style=\" font-family:\'SimSun\'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
                                            "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>")

    def reset(self):
        self.actionsdf.triggered.connect(self.reset_all)


class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)
        self.setupUi(self)


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    ui = MainWindow()
    ui.button_click()
    ui.reset()
    ui.show()
    sys.exit(app.exec_())