QT Python从第一个窗口到第二个窗口提供参数

时间:2018-09-16 19:41:47

标签: python pyqt5

这是我要在main.py中初始化为输入值的框,并禁用按钮,直到lineedits和textedits的3个值需要范围和类型。这将是第一个向用户显示的窗口。 input_box.py

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

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

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Input(object):
    def setupUi_Input(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(362, 170)
        self.layoutWidget = QtWidgets.QWidget(Dialog)
        self.layoutWidget.setGeometry(QtCore.QRect(20, 20, 319, 131))
        self.layoutWidget.setObjectName("layoutWidget")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.layoutWidget)
        self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.splitter_7 = QtWidgets.QSplitter(self.layoutWidget)
        self.splitter_7.setOrientation(QtCore.Qt.Vertical)
        self.splitter_7.setObjectName("splitter_7")
        self.RandomLabel = QtWidgets.QLabel(self.splitter_7)
        self.RandomLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.RandomLabel.setObjectName("RandomLabel")
        self.RandomtextEdit = QtWidgets.QPlainTextEdit(self.splitter_7)
        self.RandomtextEdit.setObjectName("RandomtextEdit")
        self.gridLayout_3.addWidget(self.splitter_7, 0, 0, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.LamdaEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.LamdaEdit.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
        self.LamdaEdit.setObjectName("LamdaEdit")
        self.gridLayout.addWidget(self.LamdaEdit, 1, 1, 1, 1)
        self.TmodlineEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.TmodlineEdit.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
        self.TmodlineEdit.setObjectName("TmodlineEdit")
        self.gridLayout.addWidget(self.TmodlineEdit, 0, 1, 1, 1)
        self.LamdaLabel = QtWidgets.QLabel(self.layoutWidget)
        self.LamdaLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.LamdaLabel.setObjectName("LamdaLabel")
        self.gridLayout.addWidget(self.LamdaLabel, 1, 0, 1, 1)
        self.TmodLabel = QtWidgets.QLabel(self.layoutWidget)
        self.TmodLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.TmodLabel.setObjectName("TmodLabel")
        self.gridLayout.addWidget(self.TmodLabel, 0, 0, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.CalcPushButton = QtWidgets.QPushButton(self.layoutWidget)
        self.CalcPushButton.setObjectName("CalcPushButton")
        self.gridLayout_2.addWidget(self.CalcPushButton, 1, 0, 1, 1)
        self.gridLayout_3.addLayout(self.gridLayout_2, 0, 1, 1, 1)

        self.retransUi_Input(Dialog)
        QtCore.QMetaObject.connectSlotsByName(Dialog)

    def retransUi_Input(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.RandomLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">R</span></p></body></html>"))
        self.LamdaLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">λ</span></p></body></html>"))
        self.TmodLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:14pt;\">T</span><span style=\" font-size:14pt; vertical-align:sub;\">mod</span></p></body></html>"))
        self.CalcPushButton.setText(_translate("Dialog", "Solve"))

这是第二次初始化.ui并将其转换为.py文件。它必须是用户输入并按下按钮的结果输出。好吧,必须在第一个窗口的按钮按下后才能显示。

output_box.py

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

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

from PyQt5 import QtCore, QtGui, QtWidgets

class Ui_Output(object):
    def setupUi_Output(self, OneChannelSystemMassService):
        OneChannelSystemMassService.setObjectName("OneChannelSystemMassService")
        OneChannelSystemMassService.resize(1209, 588)
        self.widget = QtWidgets.QWidget(OneChannelSystemMassService)
        self.widget.setGeometry(QtCore.QRect(0, 0, 1211, 591))
        self.widget.setObjectName("widget")
        self.gridLayout = QtWidgets.QGridLayout(self.widget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.TimeLabel = QtWidgets.QLabel(self.widget)
        self.TimeLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.TimeLabel.setObjectName("TimeLabel")
        self.gridLayout.addWidget(self.TimeLabel, 0, 0, 1, 1)
        self.EventLabel = QtWidgets.QLabel(self.widget)
        self.EventLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.EventLabel.setObjectName("EventLabel")
        self.gridLayout.addWidget(self.EventLabel, 0, 1, 1, 1)
        self.OrderLabel = QtWidgets.QLabel(self.widget)
        self.OrderLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.OrderLabel.setObjectName("OrderLabel")
        self.gridLayout.addWidget(self.OrderLabel, 0, 2, 1, 1)
        self.WaitLabel = QtWidgets.QLabel(self.widget)
        self.WaitLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.WaitLabel.setObjectName("WaitLabel")
        self.gridLayout.addWidget(self.WaitLabel, 0, 3, 1, 1)
        self.SimpleLabel = QtWidgets.QLabel(self.widget)
        self.SimpleLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.SimpleLabel.setObjectName("SimpleLabel")
        self.gridLayout.addWidget(self.SimpleLabel, 0, 4, 1, 1)
        self.NoteLabel = QtWidgets.QLabel(self.widget)
        self.NoteLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.NoteLabel.setObjectName("NoteLabel")
        self.gridLayout.addWidget(self.NoteLabel, 0, 5, 1, 1)
        self.TimetextEdit = QtWidgets.QTextEdit(self.widget)
        self.TimetextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.TimetextEdit.setObjectName("TimetextEdit")
        self.gridLayout.addWidget(self.TimetextEdit, 1, 0, 1, 1)
        self.EventtextEdit = QtWidgets.QTextEdit(self.widget)
        self.EventtextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.EventtextEdit.setObjectName("EventtextEdit")
        self.gridLayout.addWidget(self.EventtextEdit, 1, 1, 1, 1)
        self.OrdertextEdit = QtWidgets.QTextEdit(self.widget)
        self.OrdertextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.OrdertextEdit.setObjectName("OrdertextEdit")
        self.gridLayout.addWidget(self.OrdertextEdit, 1, 2, 1, 1)
        self.WaittextEdit = QtWidgets.QTextEdit(self.widget)
        self.WaittextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.WaittextEdit.setObjectName("WaittextEdit")
        self.gridLayout.addWidget(self.WaittextEdit, 1, 3, 1, 1)
        self.SimpletextEdit = QtWidgets.QTextEdit(self.widget)
        self.SimpletextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.SimpletextEdit.setObjectName("SimpletextEdit")
        self.gridLayout.addWidget(self.SimpletextEdit, 1, 4, 1, 1)
        self.NotetextEdit = QtWidgets.QTextEdit(self.widget)
        self.NotetextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.NotetextEdit.setObjectName("NotetextEdit")
        self.gridLayout.addWidget(self.NotetextEdit, 1, 5, 1, 1)

        self.retransUi_Output(OneChannelSystemMassService)
        QtCore.QMetaObject.connectSlotsByName(OneChannelSystemMassService)

    def retransUi_Output(self, OneChannelSystemMassService):
        _translate = QtCore.QCoreApplication.translate
        OneChannelSystemMassService.setWindowTitle(_translate("OneChannelSystemMassService", "Dialog"))
        self.TimeLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Time</span></p></body></html>"))
        self.EventLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Event</span></p></body></html>"))
        self.OrderLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Order</span></p></body></html>"))
        self.WaitLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">T</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">ожид.</span></p></body></html>"))
        self.SimpleLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">T</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">пр</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">.</span></p></body></html>"))
        self.NoteLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Note</span></p></body></html>"))

这是主程序,它可以在整个UI中正常运行,这是我运行该程序所要启动的。

main.py

from sys import argv

from PyQt5 import (QtCore, QtWidgets)

from PyQt5.QtGui import (QDoubleValidator, QIntValidator)

#from input_box import Ui_Input
#from output_box import Ui_Output


class SecondWindow(QtWidgets.QWidget):
    def __init__(self, parent = None):
        super().__init__(parent, QtCore.Qt.Window)
        self.build()

    def build(self):
        self.setObjectName("OneChannelSystemMassService")
        self.resize(1209, 588)
        self.widget.setGeometry(QtCore.QRect(0, 0, 1211, 591))
        self.widget.setObjectName("widget")
        self.gridLayout = QtWidgets.QGridLayout(self.widget)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setObjectName("gridLayout")
        self.TimeLabel = QtWidgets.QLabel(self.widget)
        self.TimeLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.TimeLabel.setObjectName("TimeLabel")
        self.gridLayout.addWidget(self.TimeLabel, 0, 0, 1, 1)
        self.EventLabel = QtWidgets.QLabel(self.widget)
        self.EventLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.EventLabel.setObjectName("EventLabel")
        self.gridLayout.addWidget(self.EventLabel, 0, 1, 1, 1)
        self.OrderLabel = QtWidgets.QLabel(self.widget)
        self.OrderLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.OrderLabel.setObjectName("OrderLabel")
        self.gridLayout.addWidget(self.OrderLabel, 0, 2, 1, 1)
        self.WaitLabel = QtWidgets.QLabel(self.widget)
        self.WaitLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.WaitLabel.setObjectName("WaitLabel")
        self.gridLayout.addWidget(self.WaitLabel, 0, 3, 1, 1)
        self.SimpleLabel = QtWidgets.QLabel(self.widget)
        self.SimpleLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.SimpleLabel.setObjectName("SimpleLabel")
        self.gridLayout.addWidget(self.SimpleLabel, 0, 4, 1, 1)
        self.NoteLabel = QtWidgets.QLabel(self.widget)
        self.NoteLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.NoteLabel.setObjectName("NoteLabel")
        self.gridLayout.addWidget(self.NoteLabel, 0, 5, 1, 1)
        self.TimetextEdit = QtWidgets.QTextEdit(self.widget)
        self.TimetextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.TimetextEdit.setObjectName("TimetextEdit")
        self.gridLayout.addWidget(self.TimetextEdit, 1, 0, 1, 1)
        self.EventtextEdit = QtWidgets.QTextEdit(self.widget)
        self.EventtextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.EventtextEdit.setObjectName("EventtextEdit")
        self.gridLayout.addWidget(self.EventtextEdit, 1, 1, 1, 1)
        self.OrdertextEdit = QtWidgets.QTextEdit(self.widget)
        self.OrdertextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.OrdertextEdit.setObjectName("OrdertextEdit")
        self.gridLayout.addWidget(self.OrdertextEdit, 1, 2, 1, 1)
        self.WaittextEdit = QtWidgets.QTextEdit(self.widget)
        self.WaittextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.WaittextEdit.setObjectName("WaittextEdit")
        self.gridLayout.addWidget(self.WaittextEdit, 1, 3, 1, 1)
        self.SimpletextEdit = QtWidgets.QTextEdit(self.widget)
        self.SimpletextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.SimpletextEdit.setObjectName("SimpletextEdit")
        self.gridLayout.addWidget(self.SimpletextEdit, 1, 4, 1, 1)
        self.NotetextEdit = QtWidgets.QTextEdit(self.widget)
        self.NotetextEdit.setMaximumSize(QtCore.QSize(1600, 16777215))
        self.NotetextEdit.setObjectName("NotetextEdit")
        self.gridLayout.addWidget(self.NotetextEdit, 1, 5, 1, 1)

        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("OneChannelSystemMassService", "Dialog"))
        self.TimeLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Время</span></p></body></html>"))
        self.EventLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Событие</span></p></body></html>"))
        self.OrderLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Очер.</span></p></body></html>"))
        self.WaitLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">T</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">ожид.</span></p></body></html>"))
        self.SimpleLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">T</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">пр</span><span style=\" font-size:12pt; font-weight:600; vertical-align:sub;\">.</span></p></body></html>"))
        self.NoteLabel.setText(_translate("OneChannelSystemMassService", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">Примечание</span></p></body></html>"))


class UI(QtWidgets.QWidget):
    def __init__(self, parent = None):
        super().__init__(parent)
        self.secondWin = None
        self.build()

        self.CalcPushButton.setEnabled(False)
        self.TmodlineEdit.textEdited.connect(lambda: self.CalcPushButton.setEnabled(
            self.timemodisfloat(self.TmodlineEdit.text()) and
            self.intenseisint(self.LamdaEdit.text()) and
            self.list_isfloat(self.RandomtextEdit.toPlainText().split())
        ))
        self.LamdaEdit.textEdited.connect(lambda: self.CalcPushButton.setEnabled(
            self.timemodisfloat(self.TmodlineEdit.text()) and
            self.intenseisint(self.LamdaEdit.text()) and
            self.list_isfloat(self.RandomtextEdit.toPlainText().split())
        ))
        self.RandomtextEdit.textChanged.connect(lambda: self.CalcPushButton.setEnabled(
            self.timemodisfloat(self.TmodlineEdit.text()) and
            self.intenseisint(self.LamdaEdit.text()) and
            self.list_isfloat(self.RandomtextEdit.toPlainText().split())
        ))
        self.CalcPushButton.clicked.connect(lambda: self.system_mass_service(timeout=float(self.TmodlineEdit.text()),
                                                                     intense_order=int(self.LamdaEdit.text()),
                                                                     r=[float(i) for i in
                                                                        self.RandomtextEdit.toPlainText().split()]))

        #QLocale.setDefault(QLocale(QLocale.English))
        self.TmodlineEdit.setValidator(QDoubleValidator(0.0, 9.9, 2, self.TmodlineEdit).setLocale(QtCore.QLocale(QtCore.QLocale.English)))
        self.LamdaEdit.setValidator(QIntValidator(1,9,self.LamdaEdit))
        self.TmodlineEdit.setText('2.5')
        self.LamdaEdit.setText('4')

        self.RandomtextEdit.setPlainText('0.088962 0.703284 0.509909 0.528578 0.643960 0.623277 0.424123 0.208239 0.377270 0.594395 0.382943 0.394609 0.797638 0.923129 0.421962 0.817674 0.549930 0.665823 0.777163 0.925364 0.616999 0.158099 0.316650 0.851570 0.856125 0.416551 0.742470 0.240783 0.387549 0.322630')

    def build(self):
        self.setObjectName("Dialog")
        self.resize(362, 170)
        self.layoutWidget = QtWidgets.QWidget(self)
        self.layoutWidget.setGeometry(QtCore.QRect(20, 20, 319, 131))
        self.layoutWidget.setObjectName("layoutWidget")
        self.gridLayout_3 = QtWidgets.QGridLayout(self.layoutWidget)
        self.gridLayout_3.setContentsMargins(0, 0, 0, 0)
        self.gridLayout_3.setObjectName("gridLayout_3")
        self.splitter_7 = QtWidgets.QSplitter(self.layoutWidget)
        self.splitter_7.setOrientation(QtCore.Qt.Vertical)
        self.splitter_7.setObjectName("splitter_7")
        self.RandomLabel = QtWidgets.QLabel(self.splitter_7)
        self.RandomLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.RandomLabel.setObjectName("RandomLabel")
        self.RandomtextEdit = QtWidgets.QPlainTextEdit(self.splitter_7)
        self.RandomtextEdit.setObjectName("RandomtextEdit")
        self.gridLayout_3.addWidget(self.splitter_7, 0, 0, 1, 1)
        self.gridLayout_2 = QtWidgets.QGridLayout()
        self.gridLayout_2.setObjectName("gridLayout_2")
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.LamdaEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.LamdaEdit.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
        self.LamdaEdit.setObjectName("LamdaEdit")
        self.gridLayout.addWidget(self.LamdaEdit, 1, 1, 1, 1)
        self.TmodlineEdit = QtWidgets.QLineEdit(self.layoutWidget)
        self.TmodlineEdit.setInputMethodHints(QtCore.Qt.ImhDigitsOnly)
        self.TmodlineEdit.setObjectName("TmodlineEdit")
        self.gridLayout.addWidget(self.TmodlineEdit, 0, 1, 1, 1)
        self.LamdaLabel = QtWidgets.QLabel(self.layoutWidget)
        self.LamdaLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.LamdaLabel.setObjectName("LamdaLabel")
        self.gridLayout.addWidget(self.LamdaLabel, 1, 0, 1, 1)
        self.TmodLabel = QtWidgets.QLabel(self.layoutWidget)
        self.TmodLabel.setAlignment(QtCore.Qt.AlignCenter)
        self.TmodLabel.setObjectName("TmodLabel")
        self.gridLayout.addWidget(self.TmodLabel, 0, 0, 1, 1)
        self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
        self.CalcPushButton = QtWidgets.QPushButton(self.layoutWidget)
        self.CalcPushButton.setObjectName("CalcPushButton")
        self.gridLayout_2.addWidget(self.CalcPushButton, 1, 0, 1, 1)
        self.gridLayout_3.addLayout(self.gridLayout_2, 0, 1, 1, 1)

        _translate = QtCore.QCoreApplication.translate
        self.setWindowTitle(_translate("Dialog", "Dialog"))
        self.RandomLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">R</span></p></body></html>"))
        self.LamdaLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:12pt; font-weight:600;\">λ</span></p></body></html>"))
        self.TmodLabel.setText(_translate("Dialog", "<html><head/><body><p align=\"center\"><span style=\" font-size:14pt;\">T</span><span style=\" font-size:14pt; vertical-align:sub;\">mod</span></p></body></html>"))
        self.CalcPushButton.setText(_translate("Dialog", "Вычислить"))


    def intenseisint(self, value):
        try:
            int(value)
        except ValueError:
            return False
        else:
            if int(value) > 0:
                return True
            else:
                return False

    def timemodisfloat(self, value):
        try:
            float(value)
        except ValueError:
            return False
        else:
            if float(value) > 0.0:
                return True
            else:
                return False

    def elem_isfloat(self, value):
        try:
            float(value)
        except ValueError:
            return False
        else:
            if 0.0 < float(value) < 1.0:
                return True
            else:
                return False

    def list_isfloat(self, list_):
        return all([self.elem_isfloat(elem) for elem in list_])

    def system_mass_service(self, timeout: float, intense_order: int, r: list):
        # timeout = self.TmodlineEdit.text
        # intense_order = self.LamdaEdit.text
        # r = [float(i) for i in self.RandomtextEdit.value.split]
        if not self.secondWin:
            self.secondWin = SecondWindow(self)
        self.secondWin.show()

        time, event, order, note = 0.0, '', 0, ''
        time_list, wait_list, event_list, order_list = [time], [time], [event], [order]
        simple_list, arrival_list, over_list, note_list = [], [], [], []
        from numpy import log as ln
        arrival_list.append(time - 1 / intense_order * ln(r[0]))
        if 0 <= r[1] <= 0.5:
            over_list.append(arrival_list[0] + 0.2)
        else:
            over_list.append(arrival_list[0] + 0.3)
        time = arrival_list[-1] - time
        time_list.append(time)
        simple_list.append(time)
        note_list.append('З1 = 0 - 1 / ' + str(intense_order) + ' * ln(' + str(r[0]) + ') = ' + str(arrival_list[-1]))
        for i in range(2, len(r), 1):
            if arrival_list[-1] < over_list[-1]:
                arrival_list.append(arrival_list[-1] - 1 / intense_order * ln(r[i]))
                event = 'Приход заявки №' + str(arrival_list.index(arrival_list[-1]))
                note = 'З' + str(arrival_list.index(arrival_list[-1]) + 1) + ' = ' + str(
                    arrival_list[-2]) + ' - 1 / ' + str(intense_order) + ' * ln(' + str(r[i]) + ') = ' + str(
                    arrival_list[-1])
            elif arrival_list[-1] > over_list[-1] and 0 <= r[i] <= 0.5:
                over_list.append(over_list[-1] + 0.2)
                event = 'Уход заявки №' + str(over_list.index(over_list[-1]))
                wait_list.append(wait_list[-1] + over_list[-2] - arrival_list[over_list.index(over_list[-1])])
                note = 'К' + str(over_list.index(over_list[-1]) + 1) + ' = ' + str(
                    over_list[-1] - 0.2) + ' + 0.2 = ' + str(over_list[-1])
            elif arrival_list[-1] > over_list[-1] and 0.51 <= r[i] <= 1.0:
                over_list.append(over_list[-1] + 0.3)
                event = 'Уход заявки №' + str(over_list.index(over_list[-1]))
                wait_list.append(wait_list[-1] + over_list[-2] - arrival_list[over_list.index(over_list[-1])])
                note = 'К' + str(over_list.index(over_list[-1]) + 1) + ' = ' + str(
                    over_list[-1] - 0.3) + ' + 0.3 = ' + str(over_list[-1])
            else:
                arrival_list.append(arrival_list[-1] - 1 / intense_order * ln(r[i]))
                event = 'Приход заявки №' + str(arrival_list.index(arrival_list[-1]))
                note = 'З' + str(arrival_list.index(arrival_list[-1]) + 1) + ' = ' + str(
                    arrival_list[-2]) + ' - 1 / ' + str(intense_order) + ' * ln(' + str(r[i]) + ') = ' + str(
                    arrival_list[-1])
                note_list.append(note)
                event_list.append(event)
                if 0 <= r[i] <= 0.5:
                    over_list.append(over_list[-1] + 0.2)
                    event = 'Уход заявки №' + str(over_list.index(over_list[-1]))
                    wait_list.append(wait_list[-1] + over_list[-2] - arrival_list[over_list.index(over_list[-1])])
                    note = 'К' + str(over_list.index(over_list[-1]) + 1) + ' = ' + str(
                        over_list[-1] - 0.2) + ' + 0.2 = ' + str(over_list[-1])
                else:
                    over_list.append(over_list[-1] + 0.3)
                    event = 'Уход заявки №' + str(over_list.index(over_list[-1]))
                    wait_list.append(wait_list[-1] + over_list[-2] - arrival_list[over_list.index(over_list[-1])])
                    note = 'К' + str(over_list.index(over_list[-1]) + 1) + ' = ' + str(
                        over_list[-1] - 0.3) + ' + 0.3 = ' + str(over_list[-1])
            time = min(arrival_list[-1], over_list[-1])
            time_list.append(time)
            event_list.append(event)
            order = len(arrival_list) - len(over_list)
            order_list.append(order)
            if time == over_list[0]:
                if 0 <= r[i] <= 0.5:
                    note_list.append('К1 = ' + str(over_list[0] - 0.2) + ' + 0.2 = ' + str(over_list[0]))
                else:
                    note_list.append('К1 = ' + str(over_list[0] - 0.3) + ' + 0.3 = ' + str(over_list[0]))
            note_list.append(note)
            if time > timeout:
                wait_list.remove(0.0)
                break
        self.TimetextEdit.setPlainText('\n'.join([str(i) for i in time_list]))
        self.EventtextEdit.setPlainText('\n'.join([str(i) for i in event_list]))
        self.OrdertextEdit.setPlainText('\n'.join([str(i) for i in order_list]))
        self.WaittextEdit.setPlainText('\n'.join([str(i) for i in wait_list]))
        self.SimpletextEdit.setPlainText('\n'.join([str(i) for i in simple_list]))
        self.NotetextEdit.setPlainText('\n'.join([str(i) for i in note_list]))

if __name__ == '__main__':
    app = QtWidgets.QApplication(argv)
    window = UI()
    window.show()
    exit(app.exec_())

所以我无法解决我的按下按钮错误,因为解释器没有告诉我应该在哪里寻找。 请使其工作。 UPD 是的,我修复了.toPlainText() 程序启动,但是当我按下CalcButton时Python冻结了

0 个答案:

没有答案