赞
踩
- import os
-
- import numpy as np
- import pandas as pd
- import pyecharts.options as opts
- from pyecharts.charts import Line
- from PySide2 import QtCore
- from PySide2.QtCore import QDir, QFile, QObject, Qt
- from PySide2.QtGui import QIcon
- from PySide2.QtUiTools import QUiLoader
- from PySide2.QtWebEngineWidgets import QWebEngineView
- from PySide2.QtWidgets import (QAbstractItemView, QApplication, QCheckBox,
- QDialog, QDoubleSpinBox, QFileDialog,
- QFileSystemModel, QFormLayout, QInputDialog,
- QLabel, QLayout, QLineEdit, QMessageBox,
- QPlainTextEdit, QPushButton, QStyle, QTableView,
- QTreeView, QVBoxLayout, QWidget)
-
- # pyinstaller s.spec
-
-
- class gui(QObject):
- def __init__(self):
- QObject.__init__(self)
- qfile_gui = QFile('to_bridges.ui')
- qfile_gui.open(QFile.ReadOnly)
- self.ui = QUiLoader().load(qfile_gui)
- self.ui.pushButton.clicked.connect(self.plot)
-
- def plot(self):
- x = ['440', '500', '675', '870', '1020']
- y1 = [0.631, 0.673, 0.62, 0.481, 0.469]
- y15 = [0.108, 0.14, 0.172, 0.131, 0.181]
- lab = ['1', '15']
- w = self.ui.scrollArea.width()
- h = self.ui.scrollArea.height()
- li = (Line(
- init_opts=opts.InitOpts(width=str(w) + "px",
- height=str(h) +
- 'px')).add_xaxis(x))
- for i, d in zip(lab, [y1, y15]):
- li = li.add_yaxis(i, d)
- #设置浏览器网页为pyecharts图
- bro = QWebEngineView()
- bro.setHtml(li.render_embed())
- self.ui.scrollArea.setWidget(bro)
-
-
- app = QApplication([])
- stats = gui()
- app.setWindowIcon(QIcon('./resource/icon.ico'))
- stats.ui.show()
- app.exec_()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。