1 Star 0 Fork 308

northseafishoo / PyQt

forked from PyQt5 / PyQt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
LineChart.py 1.03 KB
一键复制 编辑 原始数据 按行查看 历史
Irony 提交于 2021-07-13 14:52 . support PySide2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2017年12月19日
@author: Irony
@site: https://pyqt.site , https://github.com/PyQt5
@email: 892768447@qq.com
@file: LineChart
@description:
"""
import sys
try:
from PyQt5.QtChart import QChartView, QLineSeries, QChart
from PyQt5.QtGui import QPainter
from PyQt5.QtWidgets import QApplication
except ImportError:
from PySide2.QtGui import QPainter
from PySide2.QtWidgets import QApplication
from PySide2.QtCharts import QtCharts
QChartView = QtCharts.QChartView
QChart = QtCharts.QChart
QLineSeries = QtCharts.QLineSeries
if __name__ == '__main__':
app = QApplication(sys.argv)
chart = QChart()
chart.setTitle('Line Chart 1')
series = QLineSeries(chart)
series.append(0, 6)
series.append(2, 4)
chart.addSeries(series)
chart.createDefaultAxes() # 创建默认轴
view = QChartView(chart)
view.setRenderHint(QPainter.Antialiasing) # 抗锯齿
view.resize(800, 600)
view.show()
sys.exit(app.exec_())
Python
1
https://gitee.com/northseafishoo/PyQt.git
git@gitee.com:northseafishoo/PyQt.git
northseafishoo
PyQt
PyQt
master

搜索帮助