Пример #1
0
    def createSplineChart(self):
        chart = QChart()
        chart.setTitle("Spline chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QSplineSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Пример #2
0
    def createSplineChart(self):
        chart = QChart()
        chart.setTitle("Spline chart")

        for i, data_list in enumerate(self.m_dataTable):
            series = QSplineSeries(chart)
            for value, _ in data_list:
                series.append(value)

            series.setName("Series " + str(i))
            chart.addSeries(series)

        chart.createDefaultAxes()

        return chart
Пример #3
0
class BalanceHistoryChartView(QChartView):
    """
    Chart that displays the balance between several dates
    from an account, token or whole portfolio
    """

    def __init__(self,  *args,  **kwargs):
        super().__init__(*args, **kwargs)

        self.chart = QChart()
        self.FIAT_CURRENCY = confighandler.get_fiat_currency()

    def setupChartWithData(self, selectiontype, name=None):
        """
        Chart gets updated displaying new data.
        The data gets extracted from cbalancehistory, according 
        to the selection

        Parameters:
            - selectiontype : in ('account','token','all')
            - name: str, corresponds to account/token on cbalancehistory

        """
        self.chart = QChart()

        self.chart.setTheme(QChart.ChartThemeDark)
        self.chart.setAnimationOptions(QChart.SeriesAnimations)
        self.chart.setBackgroundBrush(QBrush(QColor('#19232d')))
#         self.chart.setTitle("")
#         self.chart.setTitleBrush(QBrush(QColor('white')))

        # Data
        # Get data
        if selectiontype == 'token':
            assert(name is not None)
            data = chistoricalbalances.get_balances_with_token_tuple(name)
        elif selectiontype == 'account':
            assert(name is not None)
            data = chistoricalbalances.get_balances_with_account_tuple(name)
        elif selectiontype == 'all':
            data = chistoricalbalances.get_balances_by_day_tuple()
        # Separate balance_btc from balance_fiat
        dates, balances_btc, balances_fiat = [], [], []
        for date in data:
            dates.append(int(date))
            balances_btc.append(data[date][0])
            balances_fiat.append(data[date][1])

        # Series
        self.btcseries = QSplineSeries()
        self.fiatseries = QSplineSeries()
        for date, balance_btc, balance_fiat in zip(dates, balances_btc, balances_fiat):
            date = datetime.fromtimestamp(date)
            date = datetime(date.year, date.month, date.day)
            dateQ = QDateTime(date).toMSecsSinceEpoch()
            self.btcseries.append(dateQ, balance_btc)
            self.fiatseries.append(dateQ, balance_fiat)

        # Append current point
        currentdate = QDateTime(datetime.today()).toMSecsSinceEpoch()
        if selectiontype == "all":
            # Append current balances
            self.btcseries.append(currentdate,
                                  cbalances.get_total_balance_all_accounts())
            self.fiatseries.append(currentdate,
                                   cbalances.get_total_balance_all_accounts_fiat())
        elif name != '':
            if selectiontype == "account":
                # Append current balances
                self.btcseries.append(
                    currentdate, cbalances.get_total_account_balance(name))
                self.fiatseries.append(
                    currentdate, cbalances.get_total_account_balance_fiat(name))
            elif selectiontype == "token":
                pass

        # Axis X (Dates)
        self.x_axis = QDateTimeAxis()
        self.x_axis.setTickCount(11)
        self.x_axis.setLabelsAngle(70)
        self.x_axis.setFormat("dd-MM-yy")
        self.x_axis.setTitleText(self.tr('Date'))

        # Axis Y (Balances)
        # BTC
        self.y_axis_btc = QValueAxis()
        if len(balances_btc) > 0:
            self.y_axis_btc.setMax(max(balances_btc)*1.1)
            self.y_axis_btc.setMin(min(balances_btc)*0.9)
        # Fiat
        self.y_axis_fiat = QValueAxis()
        if len(balances_fiat) > 0:
            self.y_axis_fiat.setMax(max(balances_fiat)*1.1)
            self.y_axis_fiat.setMin(min(balances_fiat)*0.9)

        self.chart.addAxis(self.y_axis_btc, Qt.AlignLeft)
        self.chart.addAxis(self.y_axis_fiat, Qt.AlignRight)
        self.chart.addAxis(self.x_axis, Qt.AlignBottom)

        # Add series to chart
        # BTC
        self.btcseries.setName("BTC")
        self.chart.addSeries(self.btcseries)
        self.btcseries.attachAxis(self.x_axis)
        self.btcseries.attachAxis(self.y_axis_btc)
        # Fiat
        self.fiatseries.setName(self.FIAT_CURRENCY.upper())
        self.chart.addSeries(self.fiatseries)
        self.fiatseries.attachAxis(self.x_axis)
        self.fiatseries.attachAxis(self.y_axis_fiat)

        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)
        self.setStyleSheet("border: 0px")
Пример #4
0
class ChartView(QChartView, QChart):
    def __init__(self, *args, **kwargs):
        super(ChartView, self).__init__(*args, **kwargs)
        self.resize(800, 600)
        self.setRenderHint(QPainter.Antialiasing)  # 抗锯齿
        self.chart_init()
        self.timer_init()

    def timer_init(self):
        #使用QTimer,2秒触发一次,更新数据
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.drawLine)
        self.timer.start(200)

    def chart_init(self):
        self.chart = QChart()
        self.series = QSplineSeries()
        #设置曲线名称
        self.series.setName("实时数据")
        #把曲线添加到QChart的实例中
        self.chart.addSeries(self.series)
        #声明并初始化X轴,Y轴
        self.dtaxisX = QDateTimeAxis()
        self.vlaxisY = QValueAxis()
        #设置坐标轴显示范围
        self.dtaxisX.setMin(QDateTime.currentDateTime().addSecs(-300 * 1))
        self.dtaxisX.setMax(QDateTime.currentDateTime().addSecs(0))
        self.vlaxisY.setMin(0)
        self.vlaxisY.setMax(1500)
        #设置X轴时间样式
        self.dtaxisX.setFormat("MM月dd hh:mm:ss")
        #设置坐标轴上的格点
        self.dtaxisX.setTickCount(6)
        self.vlaxisY.setTickCount(11)
        #设置坐标轴名称
        self.dtaxisX.setTitleText("时间")
        self.vlaxisY.setTitleText("量程")
        #设置网格不显示
        self.vlaxisY.setGridLineVisible(False)
        #把坐标轴添加到chart中
        self.chart.addAxis(self.dtaxisX, Qt.AlignBottom)
        self.chart.addAxis(self.vlaxisY, Qt.AlignLeft)
        #把曲线关联到坐标轴
        self.series.attachAxis(self.dtaxisX)
        self.series.attachAxis(self.vlaxisY)

        self.setChart(self.chart)

    def drawLine(self):
        #获取当前时间
        bjtime = QDateTime.currentDateTime()
        #更新X轴坐标
        self.dtaxisX.setMin(QDateTime.currentDateTime().addSecs(-300 * 1))
        self.dtaxisX.setMax(QDateTime.currentDateTime().addSecs(0))
        #当曲线上的点超出X轴的范围时,移除最早的点
        if (self.series.count() > 149):
            self.series.removePoints(0, self.series.count() - 149)
        #产生随即数
        yint = random.randint(0, 1500)
        #添加数据到曲线末端
        self.series.append(bjtime.toMSecsSinceEpoch(), yint)
class MainWindow(QMainWindow, Ui_MainWindow):
    def __init__(self, weight_path, out_file_path, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.setWindowTitle("VAT ROLL COMPARE LABEL TOOL" + " " + CODE_VER)
        self.showMaximized()
        '''按键绑定'''
        # 输入媒体
        self.import_media_pushButton.clicked.connect(self.import_media)  # 导入
        self.start_predict_pushButton.clicked.connect(
            self.predict_button_click)  # 开始推理
        # 输出媒体
        self.open_predict_file_pushButton.clicked.connect(
            self.open_file_in_browser)  # 文件中显示推理视频
        # 下方
        self.play_pushButton.clicked.connect(
            self.play_pause_button_click)  # 播放
        self.pause_pushButton.clicked.connect(
            self.play_pause_button_click)  # 暂停
        self.button_dict = dict()
        self.button_dict.update({
            "import_media_pushButton": self.import_media_pushButton,
            "start_predict_pushButton": self.start_predict_pushButton,
            "open_predict_file_pushButton": self.open_predict_file_pushButton,
            "play_pushButton": self.play_pushButton,
            "pause_pushButton": self.pause_pushButton,
        })
        '''媒体流绑定输出'''
        self.input_player = QMediaPlayer()  # 媒体输入的widget
        self.input_player.setVideoOutput(self.input_video_widget)
        self.input_player.positionChanged.connect(
            self.change_slide_bar)  # 播放进度条

        self.output_player = QMediaPlayer()  # 媒体输出的widget
        self.output_player.setVideoOutput(self.output_video_widget)
        '''初始化GPU chart'''
        self.series = QSplineSeries()
        self.chart_init()
        '''初始化GPU定时查询定时器'''
        # 使用QTimer,0.5秒触发一次,更新数据
        self.timer = QTimer(self)
        self.timer.timeout.connect(self.draw_gpu_info_chart)
        self.timer.start(500)

        # 播放时长, 以 input 的时长为准
        self.video_length = 0
        self.out_file_path = out_file_path
        # 推理使用另外一线程
        self.predict_handler_thread = PredictHandlerThread(
            self.output_player, self.out_file_path, weight_path,
            self.predict_info_plainTextEdit, self.predict_progressBar,
            self.fps_label, self.button_dict)
        # 界面美化
        self.gen_better_gui()

    def gen_better_gui(self):
        """
        美化界面
        :return:
        """
        # Play 按钮
        play_icon = QIcon()
        play_icon.addPixmap(QPixmap("./UI/icon/play.png"), QIcon.Normal,
                            QIcon.Off)
        self.play_pushButton.setIcon(play_icon)

        # Pause 按钮
        play_icon = QIcon()
        play_icon.addPixmap(QPixmap("./UI/icon/pause.png"), QIcon.Normal,
                            QIcon.Off)
        self.pause_pushButton.setIcon(play_icon)

    def chart_init(self):
        """
        初始化 GPU 折线图
        :return:
        """
        # self.gpu_info_chart._chart = QChart(title="折线图堆叠")  # 创建折线视图
        self.gpu_info_chart._chart = QChart()  # 创建折线视图
        # chart._chart.setBackgroundVisible(visible=False)      # 背景色透明
        self.gpu_info_chart._chart.setBackgroundBrush(QBrush(
            QColor("#FFFFFF")))  # 改变图背景色

        # 设置曲线名称
        self.series.setName("GPU Utilization")
        # 把曲线添加到QChart的实例中
        self.gpu_info_chart._chart.addSeries(self.series)
        # 声明并初始化X轴,Y轴
        self.dtaxisX = QDateTimeAxis()
        self.vlaxisY = QValueAxis()
        # 设置坐标轴显示范围
        self.dtaxisX.setMin(QDateTime.currentDateTime().addSecs(-300 * 1))
        self.dtaxisX.setMax(QDateTime.currentDateTime().addSecs(0))
        self.vlaxisY.setMin(0)
        self.vlaxisY.setMax(100)
        # 设置X轴时间样式
        self.dtaxisX.setFormat("hh:mm:ss")
        # 设置坐标轴上的格点
        self.dtaxisX.setTickCount(5)
        self.vlaxisY.setTickCount(10)
        # 设置坐标轴名称
        self.dtaxisX.setTitleText("Time")
        self.vlaxisY.setTitleText("Percent")
        # 设置网格不显示
        self.vlaxisY.setGridLineVisible(False)
        # 把坐标轴添加到chart中
        self.gpu_info_chart._chart.addAxis(self.dtaxisX, Qt.AlignBottom)
        self.gpu_info_chart._chart.addAxis(self.vlaxisY, Qt.AlignLeft)
        # 把曲线关联到坐标轴
        self.series.attachAxis(self.dtaxisX)
        self.series.attachAxis(self.vlaxisY)
        # 生成 折线图
        self.gpu_info_chart.setChart(self.gpu_info_chart._chart)

    def draw_gpu_info_chart(self):
        """
        绘制 GPU 折线图
        :return:
        """
        # 获取当前时间
        time_current = QDateTime.currentDateTime()
        # 更新X轴坐标
        self.dtaxisX.setMin(QDateTime.currentDateTime().addSecs(-300 * 1))
        self.dtaxisX.setMax(QDateTime.currentDateTime().addSecs(0))
        # 当曲线上的点超出X轴的范围时,移除最早的点
        remove_count = 600
        if self.series.count() > remove_count:
            self.series.removePoints(0, self.series.count() - remove_count)
        # 对 y 赋值
        # yint = random.randint(0, 100)
        gpu_info = get_gpu_info()
        yint = gpu_info[0].get("gpu_load")
        # 添加数据到曲线末端
        self.series.append(time_current.toMSecsSinceEpoch(), yint)

    def import_media(self):
        """
        导入媒体文件
        :return:
        """
        self.parameter_source = QFileDialog.getOpenFileUrl()[0]
        self.input_player.setMedia(QMediaContent(
            self.parameter_source))  # 选取视频文件

        # 设置 output 为一张图片,防止资源被占用
        path_current = str(Path.cwd().joinpath("area_dangerous\1.jpg"))
        self.output_player.setMedia(
            QMediaContent(QUrl.fromLocalFile(path_current)))

        # 将 QUrl 路径转为 本地路径str
        self.predict_handler_thread.parameter_source = self.parameter_source.toLocalFile(
        )
        self.input_player.pause()  # 显示媒体

        image_flag = os.path.splitext(
            self.predict_handler_thread.parameter_source)[-1].lower(
            ) in img_formats
        for item, button in self.button_dict.items():
            if image_flag and item in ['play_pushButton', 'pause_pushButton']:
                button.setEnabled(False)
            else:
                button.setEnabled(True)
        # self.output_player.setMedia(QMediaContent(QFileDialog.getOpenFileUrl()[0]))  # 选取视频文件

    def predict_button_click(self):
        """
        推理按钮
        :return:
        """
        # 启动线程去调用
        self.predict_handler_thread.start()

    def change_slide_bar(self, position):
        """
        进度条移动
        :param position:
        :return:
        """
        self.video_length = self.input_player.duration() + 0.1
        self.video_horizontalSlider.setValue(
            round((position / self.video_length) * 100))
        self.video_percent_label.setText(
            str(round((position / self.video_length) * 100, 2)) + '%')

    @pyqtSlot()
    def play_pause_button_click(self):
        """
        播放、暂停按钮回调事件
        :return:
        """
        name = self.sender().objectName()

        if self.parameter_source == "":
            return

        if name == "play_pushButton":
            print("play")
            self.input_player.play()
            self.output_player.play()

        elif name == "pause_pushButton":
            self.input_player.pause()
            self.output_player.pause()

    @pyqtSlot()
    def open_file_in_browser(self):
        os.system(f"start explorer {self.out_file_path}")

    @pyqtSlot()
    def closeEvent(self, *args, **kwargs):
        """
        重写关闭事件
        :param args:
        :param kwargs:
        :return:
        """
        print("Close")
Пример #6
0
app = QApplication(sys.argv)

ANGULAR_MIN = -100
ANGULAR_MAX = 100

RADIAL_MIN = -100
RADIAL_MAX = 100

series1 = QScatterSeries()
series1.setName("scatter")
for i in range(ANGULAR_MIN, ANGULAR_MAX + 1, 10):
    series1.append(i, (float(i) / RADIAL_MAX) * RADIAL_MAX + 8.0)

series2 = QSplineSeries()
series2.setName("spline")
for i in range(ANGULAR_MIN, ANGULAR_MAX + 1, 10):
    series2.append(i, (float(i) / RADIAL_MAX) * RADIAL_MAX)

series3 = QLineSeries()
series3.setName("star outer")
ad = (ANGULAR_MAX - ANGULAR_MIN) / 8.0
rd = (RADIAL_MAX - RADIAL_MIN) / 3.0 * 1.3
series3.append(ANGULAR_MIN, RADIAL_MAX)
series3.append(ANGULAR_MIN + ad * 1, RADIAL_MIN + rd)
series3.append(ANGULAR_MIN + ad * 2, RADIAL_MAX)
series3.append(ANGULAR_MIN + ad * 3, RADIAL_MIN + rd)
series3.append(ANGULAR_MIN + ad * 4, RADIAL_MAX)
series3.append(ANGULAR_MIN + ad * 5, RADIAL_MIN + rd)
series3.append(ANGULAR_MIN + ad * 6, RADIAL_MAX)
series3.append(ANGULAR_MIN + ad * 7, RADIAL_MIN + rd)
Пример #7
0
   def __createChart(self):  ##创建图表
      chart = QChart()  #创建 Chart
   ##      chart.setTitle("简单函数曲线")
      chart.legend().setVisible(True)
      self.chartView.setChart(chart)   #Chart添加到chartView

      pen=QPen()
      pen.setWidth(2)

   ##========LineSeries折线 和 ScatterSeries散点
      seriesLine = QLineSeries()
      seriesLine.setName("LineSeries折线")
      seriesLine.setPointsVisible(False)     #数据点不可见
      pen.setColor(Qt.red)
      seriesLine.setPen(pen)
      seriesLine.hovered.connect(self.do_series_hovered)    #信号 hovered
      seriesLine.clicked.connect(self.do_series_clicked)    #信号 clicked
      chart.addSeries(seriesLine)   #添加到chart

      seriesLinePoint = QScatterSeries()    #散点序列
      seriesLinePoint.setName("ScatterSeries散点")
      shape=QScatterSeries.MarkerShapeCircle  #MarkerShapeRectangle
      seriesLinePoint.setMarkerShape(shape)   #散点形状,只有2种
      seriesLinePoint.setBorderColor(Qt.yellow)
      seriesLinePoint.setBrush(QBrush(Qt.red))
      seriesLinePoint.setMarkerSize(10)      #散点大小
      seriesLinePoint.hovered.connect(self.do_series_hovered)  #信号 hovered
      seriesLinePoint.clicked.connect(self.do_series_clicked)  #信号 clicked
      chart.addSeries(seriesLinePoint)    #添加到chart

   ##======== SplineSeries 曲线和 QScatterSeries 散点
      seriesSpLine = QSplineSeries()
      seriesSpLine.setName("SplineSeries曲线")
      seriesSpLine.setPointsVisible(False)    #数据点不可见
      pen.setColor(Qt.blue)
      seriesSpLine.setPen(pen)
      seriesSpLine.hovered.connect(self.do_series_hovered)  #信号 hovered
      seriesSpLine.clicked.connect(self.do_series_clicked)  #信号 clicked


      seriesSpPoint = QScatterSeries()    #散点序列
      seriesSpPoint.setName("QScatterSeries")
      shape=QScatterSeries.MarkerShapeRectangle  #MarkerShapeCircle
      seriesSpPoint.setMarkerShape(shape) #散点形状,只有2种
      seriesSpPoint.setBorderColor(Qt.green)
      seriesSpPoint.setBrush(QBrush(Qt.blue))
      seriesSpPoint.setMarkerSize(10)     #散点大小
      seriesSpPoint.hovered.connect(self.do_series_hovered) #信号 hovered
      seriesSpPoint.clicked.connect(self.do_series_clicked) #信号 clicked

      chart.addSeries(seriesSpLine)
      chart.addSeries(seriesSpPoint)

   ##  创建缺省坐标轴
      chart.createDefaultAxes()  #创建缺省坐标轴并与序列关联
      chart.axisX().setTitleText("time(secs)")
      chart.axisX().setRange(0,10)
      chart.axisX().applyNiceNumbers()

      chart.axisY().setTitleText("value")
      chart.axisY().setRange(-2,2)
      chart.axisY().applyNiceNumbers()

      for marker in chart.legend().markers():  #QLegendMarker类型列表
         marker.clicked.connect(self.do_LegendMarkerClicked)
Пример #8
0
class TotalEquityChartView(QChartView):
    """
    Chart that displays the balance between several dates
    from an account, token or whole portfolio
    """
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.chart = QChart()

    def setupChartWithData(self, data, linecolor='#422F8A'):
        """
        Chart gets updated displaying the new data.

        Data has to be expressed on a dictionary form:
            - keys are timestamps
            - values are total balance for that timestamp
        """
        self.chart = QChart()

        self.chart.setTheme(QChart.ChartThemeDark)
        self.chart.setAnimationOptions(QChart.SeriesAnimations)
        self.chart.setBackgroundBrush(QBrush(QColor("transparent")))
        #         self.chart.setTitle("")
        #         self.chart.setTitleBrush(QBrush(QColor('white')))

        # Axis X (Dates)
        self.x_axis = QDateTimeAxis()
        self.x_axis.setTickCount(11)
        self.x_axis.setLabelsAngle(70)
        font = QFont()
        font.setFamily('Roboto')
        font.setLetterSpacing(QFont.PercentageSpacing, 110)
        font.setPointSize(8)
        self.x_axis.setLabelsFont(font)
        self.x_axis.setFormat("dd-MM-yy")
        self.x_axis.setTitleText(self.tr('Date'))
        self.x_axis.setTitleVisible(False)
        self.x_axis.setLineVisible(False)
        self.x_axis.setGridLineVisible(False)

        # Axis Y (Balances)
        self.y_axis = QValueAxis()
        if data != {}:
            self.y_axis.setMax(max(data.values()) * 1.05)
            self.y_axis.setMin(min(data.values()) * 0.95)
        # self.y_axis.setMinorGridLineVisible(False)
        self.y_axis.setLineVisible(False)
        self.y_axis.setGridLineColor(QColor("#ECE9F1"))

        self.chart.addAxis(self.y_axis, Qt.AlignLeft)
        self.chart.addAxis(self.x_axis, Qt.AlignBottom)

        # Series
        self.btcseries = QSplineSeries()
        for date in data:
            balance = data[date]
            date = QDateTime(datetime.fromtimestamp(int(float(date))))
            self.btcseries.append(date.toMSecsSinceEpoch(), balance)

        self.btcseries.setName("BTC")
        pen = QPen(QColor(linecolor))
        pen.setWidth(3)
        self.btcseries.setPen(pen)

        # Series functionality
        self.btcseries.hovered.connect(self.selectPoint)

        self.chart.addSeries(self.btcseries)
        self.btcseries.attachAxis(self.x_axis)
        self.btcseries.attachAxis(self.y_axis)

        self.setChart(self.chart)
        self.setRenderHint(QPainter.Antialiasing)
        self.setStyleSheet("border: 0px; background-color: rgba(0,0,0,0); ")

        self.chart.legend().hide()

    def selectPoint(self, point, state):
        """ Shows point where mouse is hovered """
        self.chart.setTitle(
            f"{int(point.y())} {confighandler.get_fiat_currency().upper()}")
Пример #9
0
class Example(QMainWindow):
    def __init__(self, ):
        super().__init__()
        self.bijiao = [0, 0, 0]

        self.res = ""
        self.queue = []
        self.k = -1
        self.flag = -1

        try:
            self.initUI()
            self.chart_init(10)
        except:
            traceback.print_exc()

    def initUI(self):

        icon = QtGui.QIcon()
        icon.addPixmap(
            QtGui.QPixmap("D:\\Sysytem\\Desktop\\zhong\\data\\ico.ico"),
            QtGui.QIcon.Normal, QtGui.QIcon.Off)
        self.setWindowIcon(icon)

        self.resize(1000, 700)
        self.setWindowTitle('Icon')

        self.setObjectName("清华大学得不到的学生")
        self.setWindowTitle("一枚小乖乖~")
        self.label = QLabel(self)
        self.label.setWindowTitle("清华大学得不到的学生")
        self.setWindowFlags(Qt.FramelessWindowHint)
        self.setAttribute(Qt.WA_TranslucentBackground)

        self.label.setGeometry(QtCore.QRect(15, 15, 970, self.height() - 30))
        self.label.setText("")
        palette = QtGui.QPalette()

        self.label.setStyleSheet("background-color: #fff;border-radius: 15px;")
        self.labelshadow = QGraphicsDropShadowEffect(self)
        self.labelshadow.setBlurRadius(15)
        self.labelshadow.setOffset(1, 1)
        self.label.setGraphicsEffect(self.labelshadow)

        self.label.setScaledContents(True)
        self.label.setObjectName("label")

        self.pushButton_12 = QtWidgets.QPushButton(self)
        self.pushButton_12.setGeometry(
            QtCore.QRect(self.width() - 55, 29, 20, 20))
        self.pushButton_12.setStyleSheet(
            "QPushButton{\n"
            "    background:#fc625d;\n"
            "    color:white;\n"
            "    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);font-size:20px;border-radius: 10px;font-family: 微软雅黑;\n"
            "}\n"
            "QPushButton:hover{                    \n"
            "    background:#FF2D2D;\n"
            "}\n"
            "QPushButton:pressed{\n"
            "    border: 1px solid #3C3C3C!important;\n"
            "    background:#AE0000;\n"
            "}")
        self.pushButton_12.clicked.connect(self.close)

        self.pushButton_14 = QtWidgets.QPushButton(self)
        self.pushButton_14.setGeometry(
            QtCore.QRect(self.width() - 55 - 35, 29, 20, 20))
        self.pushButton_14.setStyleSheet(
            "QPushButton{\n"
            "    background:#35cd4b;\n"
            "    color:white;\n"
            "    box-shadow: 1px 1px 3px rgba(0,0,0,0.3);font-size:20px;border-radius: 10px;font-family: 微软雅黑;\n"
            "}\n"
            "QPushButton:hover{                    \n"
            "    background:#00CC00;\n"
            "}\n"
            "QPushButton:pressed{\n"
            "    border: 1px solid #3C3C3C!important;\n"
            "    background:#009900;\n"
            "}")
        self.pushButton_14.clicked.connect(self.showMinimized)

        self.color = ["#e89291", "#c4b98b", "#81a8e1", "#8cc9c4", "#83bde2"]
        # -----------------------------------------------------------------测试数量------------------------
        error = QtWidgets.QLineEdit(self)
        error.setGeometry(QtCore.QRect(70, 70, 150, 50))
        error.setStyleSheet(
            "text-align: center;background-color: " + self.color[0] +
            ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;"
        )
        errorshadow = QGraphicsDropShadowEffect(self)
        error.setPlaceholderText("测试数量")
        errorshadow.setBlurRadius(30)
        cl = QColor("#cacaca")
        errorshadow.setColor(cl)
        error.setAlignment(Qt.AlignCenter)
        errorshadow.setOffset(0, 0)
        error.textChanged.connect(self.set_suliang)
        # error.setGraphicsEffect(errorshadow)

        # -----------------------------------------------------------------随机范围------------------------

        fan = QtWidgets.QLineEdit(self)
        fan.setGeometry(QtCore.QRect(240, 70, 150, 50))
        fan.setStyleSheet(
            "text-align: center;background-color: " + self.color[2] +
            ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;"
        )
        fanshadow = QGraphicsDropShadowEffect(self)
        fanshadow.setBlurRadius(30)
        fancl = QColor("#cacaca")
        fan.setPlaceholderText("随机范围")
        fanshadow.setColor(fancl)
        fan.setAlignment(Qt.AlignCenter)
        fanshadow.setOffset(0, 0)
        fan.textChanged.connect(self.set_fanwei)
        # fan.setGraphicsEffect(fanshadow)

        # -----------------------------------------------------------------内存块数-----------------------

        kuai = QtWidgets.QLineEdit(self)
        kuai.setGeometry(QtCore.QRect(410, 70, 150, 50))
        kuai.setStyleSheet(
            "text-align: center;background-color: " + self.color[3] +
            ";border-radius: 7px;border: 0px solid #000;color:#ffffff;font-size:20px;font-family: 微软雅黑;"
        )
        kuaishadow = QGraphicsDropShadowEffect(self)
        kuaishadow.setBlurRadius(30)
        kuaicl = QColor("#cacaca")
        kuai.setPlaceholderText("内存块数")
        kuaishadow.setColor(kuaicl)
        kuai.setAlignment(Qt.AlignCenter)
        kuaishadow.setOffset(0, 0)
        kuai.textChanged.connect(self.set_kuai)
        # kuai.setGraphicsEffect(kuaishadow)

        self.Button = QtWidgets.QPushButton(self)
        self.Button.setGeometry(QtCore.QRect(580, 70, 150, 50))
        self.Button.setStyleSheet(
            "QPushButton{text-align: center;background-color: #83bde2;"
            "border-radius: 7px;border: 0px solid #000;color:#ffffff;"
            "font-size:20px;font-family: 微软雅黑;}" + "QPushButton:hover{ " +
            "    background-color: #9ad0d0;color: white;" + "}")
        Buttonshadow = QGraphicsDropShadowEffect(self)
        Buttonshadow.setBlurRadius(30)
        Buttoncl = QColor("#cacaca")
        self.Button.setText("执行")
        Buttonshadow.setColor(Buttoncl)
        Buttonshadow.setOffset(0, 0)
        # Button.setGraphicsEffect(Buttonshadow)
        self.Button.clicked.connect(self.on_click_start)

        self.avgflag = 0

        self.qq = QtWidgets.QPushButton(self)
        self.qq.setGeometry(QtCore.QRect(750, 70, 180, 50))
        self.qq.setStyleSheet(
            "color: #000;text-align: center;background-color: #f0f0f0;border-radius: 7px;border: 0px solid #000;font-size:14px;font-family: 微软雅黑;"
        )
        self.qq.clicked.connect(self.on_avg)

        self.show()

    def on_avg(self):
        if self.avgflag == 0:
            self.series.hide()

            self.serieslru.hide()

            self.seriesopt.hide()

            self.seriesfifoavg.show()

            self.serieslruavg.show()

            self.seriesoptavg.show()
            self.avgflag = 1
        else:

            self.series.show()

            self.serieslru.show()

            self.seriesopt.show()

            self.seriesfifoavg.hide()

            self.serieslruavg.hide()

            self.seriesoptavg.hide()
            self.avgflag = 0

    def set_kuai(self, text):
        self.kuai = text

    def set_fanwei(self, text):
        self.fan = text

    def set_suliang(self, text):
        self.su = text

    def hideerror(self):
        self.error.hide()

    def set_kuaishu(self, text):
        self.kuaishu = text

    def set_yemian(self, text):
        self.yemian = text

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate

    def mousePressEvent(self, e):
        if e.button() == Qt.LeftButton:
            self.m_drag = True
            self.m_DragPosition = e.globalPos() - self.pos()
            e.accept()

    def mouseReleaseEvent(self, e):
        if e.button() == Qt.LeftButton:
            self.m_drag = False

    def mouseMoveEvent(self, e):
        try:
            if Qt.LeftButton and self.m_drag:
                self.move(e.globalPos() - self.m_DragPosition)
                e.accept()
        except:
            print("错误代码:000x0")

    def on_click_start(self):
        try:
            self.jishu = 0
            self.thread = MyThread()
            self.thread.set_su(self.su)
            self.thread.set_kuai(self.kuai)
            self.thread.set_x(self.dtaxisX)
            self.thread.set_fan(self.fan)
            self.thread.det_bijiao(self.bijiao)
            self.dailist = []
            self.avg = []
            self.avg1 = []
            self.avg2 = []
            self.dailistlru = []
            self.dailistopt = []
            self.thread.sinOut.connect(self.change)
            self.thread.start()

            # self.qq.setText("FIFO:%0.2f   LRU:%0.2f \n OPT:%0.2f" % (self.bijiao[0], self.bijiao[1], self.bijiao[2]))

        except:
            traceback.print_exc()
        # self.sinOut.emit(self.dailist)
        # self.sinOut2.emit(self.dailistlru)
        # self.sinOut3.emit(self.dailistopt)

    def change(self, dailist):
        try:
            # print(dailist)
            # arr = str.split(dailist)
            # print(arr)

            flag = 0
            start = 0
            flag = dailist.find(" ", flag)
            flag = dailist.find(" ", flag + 1)
            end = flag
            arr = str.split(dailist[start:end])

            start = flag
            flag = dailist.find(" ", flag + 1)
            flag = dailist.find(" ", flag + 1)
            end = flag
            arr1 = str.split(dailist[start:end])

            start = flag
            flag = dailist.find(" ", flag + 1)
            flag = dailist.find(" ", flag + 1)
            end = flag
            arr2 = str.split(dailist[start:end])

            self.dailist.append(QPointF(float(arr[0]), float(arr[1])))

            self.dailistlru.append(QPointF(float(arr1[0]), float(arr1[1])))

            self.dailistopt.append(QPointF(float(arr2[0]), float(arr2[1])))
            #
            self.series.replace(self.dailist)
            self.serieslru.replace(self.dailistlru)
            self.seriesopt.replace(self.dailistopt)

            if self.jishu == 0:
                self.bijiao[0] = float(arr[1])
                self.bijiao[1] = float(arr1[1])
                self.bijiao[2] = float(arr2[1])
                self.jishu = 1
            else:
                self.bijiao[0] = (float(arr[1]) + self.bijiao[0]) / 2.0
                self.bijiao[1] = (float(arr1[1]) + self.bijiao[1]) / 2.0
                self.bijiao[2] = (float(arr2[1]) + self.bijiao[2]) / 2.0
                self.jishu = self.jishu + 1

            self.avg.append(QPointF(float(arr[0]), self.bijiao[0]))
            self.avg1.append(QPointF(float(arr[0]), self.bijiao[1]))
            self.avg2.append(QPointF(float(arr[0]), self.bijiao[2]))

            # print(self.avg)
            self.seriesfifoavg.replace(self.avg)
            self.serieslruavg.replace(self.avg1)
            self.seriesoptavg.replace(self.avg2)

            self.qq.setText("FIFO:%0.2f   LRU:%0.2f \n OPT:%0.2f" %
                            (self.bijiao[0], self.bijiao[1], self.bijiao[2]))
        except:
            traceback.print_exc()

    def drawLine(self):
        self.series.replace(self.dailist)
        # print("uiy")

    def chart_init(self, su):
        self.start_num = 0
        self.chart = QChartView(self)
        self.chart.setGeometry(50, 150,
                               self.width() - 100,
                               self.height() - 150 - 50)  # 设置charView位置、大小
        self.series = QSplineSeries()
        self.series.setName("FIFO")
        self.chart.chart().addSeries(self.series)

        pen = QPen(Qt.gray)
        pen.setWidth(2)
        self.serieslru = QSplineSeries()
        self.serieslru.setPen(pen)
        self.serieslru.setName("LRU")
        self.serieslru.setColor(QColor("#e89291"))
        self.chart.chart().addSeries(self.serieslru)

        pen2 = QPen(Qt.gray)
        pen2.setWidth(2)
        self.seriesopt = QSplineSeries()
        self.seriesopt.setPen(pen2)
        self.seriesopt.setColor(QColor("#3ea54f"))
        self.seriesopt.setName("OPT")
        self.chart.chart().addSeries(self.seriesopt)

        penfifo = QPen(Qt.gray)
        penfifo.setWidth(2)
        self.seriesfifoavg = QSplineSeries()
        self.seriesfifoavg.setPen(penfifo)
        self.seriesfifoavg.setName("FIFO-avg")
        self.seriesfifoavg.setColor(QColor("#209fdf"))
        self.chart.chart().addSeries(self.seriesfifoavg)
        self.seriesfifoavg.hide()

        penavg = QPen(Qt.gray)
        penavg.setWidth(2)
        self.serieslruavg = QSplineSeries()
        self.serieslruavg.setPen(penavg)
        self.serieslruavg.setName("LRU-avg")
        self.serieslruavg.setColor(QColor("#e89291"))
        self.chart.chart().addSeries(self.serieslruavg)
        self.serieslruavg.hide()

        pen2avg = QPen(Qt.gray)
        pen2avg.setWidth(2)
        self.seriesoptavg = QSplineSeries()
        self.seriesoptavg.setPen(pen2avg)
        self.seriesoptavg.setColor(QColor("#3ea54f"))
        self.seriesoptavg.setName("OPT-avg")
        self.chart.chart().addSeries(self.seriesoptavg)
        self.seriesoptavg.hide()

        self.dtaxisX = QValueAxis()
        self.vlaxisY = QValueAxis()
        self.dtaxisX.setMin(10)
        self.dtaxisX.setMax(100)
        self.vlaxisY.setMin(0)
        self.vlaxisY.setMax(100)
        self.dtaxisX.setTickCount(6)
        self.vlaxisY.setTickCount(11)
        self.dtaxisX.setTitleText("页数")
        self.vlaxisY.setTitleText("缺页率")
        self.vlaxisY.setGridLineVisible(False)
        self.chart.chart().addAxis(self.dtaxisX, Qt.AlignBottom)
        self.chart.chart().addAxis(self.vlaxisY, Qt.AlignLeft)
        self.series.attachAxis(self.dtaxisX)
        self.series.attachAxis(self.vlaxisY)

        self.serieslru.attachAxis(self.dtaxisX)
        self.serieslru.attachAxis(self.vlaxisY)

        self.seriesopt.attachAxis(self.dtaxisX)
        self.seriesopt.attachAxis(self.vlaxisY)

        self.seriesoptavg.attachAxis(self.dtaxisX)
        self.seriesoptavg.attachAxis(self.vlaxisY)
        self.serieslruavg.attachAxis(self.dtaxisX)
        self.serieslruavg.attachAxis(self.vlaxisY)
        self.seriesfifoavg.attachAxis(self.dtaxisX)
        self.seriesfifoavg.attachAxis(self.vlaxisY)

        self.chart.chart().setTitleBrush(QBrush(Qt.cyan))
        cc = QColor("#f0f0f0")
        self.chart.setBackgroundBrush(cc)
        self.chart.setStyleSheet(
            "QChartView{ background-color: #83bde2;border-radius: 20px;}")
        self.chart.show()