Bindings for graphics lib QCustomPlot2 for PyQt5
修訂 | a8a64f904e0cada9d3b36d531cdebabd91205dcd (tree) |
---|---|
時間 | 2020-11-12 15:38:39 |
作者 | Sergey Salnikov <salsergey@gmai...> |
Commiter | Sergey Salnikov |
Update README.md
Updated example to make it really executable.
@@ -41,10 +41,20 @@ $ pip install QCustomPlot2 | ||
41 | 41 | Now let's take a look at some code: |
42 | 42 | |
43 | 43 | ```python |
44 | +import sys | |
45 | +import math | |
46 | +from PyQt5.QtCore import Qt | |
44 | 47 | from PyQt5.QtGui import QPen, QBrush, QColor |
48 | +from PyQt5.QtWidgets import QApplication, QMainWindow | |
45 | 49 | from QCustomPlot2 import * |
46 | 50 | |
51 | + | |
52 | +app = QApplication(sys.argv) | |
53 | +window = QMainWindow() | |
54 | +window.resize(800, 600) | |
55 | + | |
47 | 56 | customPlot = QCustomPlot() |
57 | +window.setCentralWidget(customPlot) | |
48 | 58 | |
49 | 59 | graph0 = customPlot.addGraph() |
50 | 60 | graph0.setPen(QPen(Qt.blue)) |
@@ -63,7 +73,12 @@ graph0.setData(x, y0) | ||
63 | 73 | graph1.setData(x, y1) |
64 | 74 | |
65 | 75 | customPlot.rescaleAxes() |
66 | -customPlot.setInteractions(QCPInteractions(QCP.iRangeDrag | QCP.iRangeZoom | QCP.iSelectPlottable)) | |
76 | +customPlot.setInteraction(QCP.iRangeDrag) | |
77 | +customPlot.setInteraction(QCP.iRangeZoom) | |
78 | +customPlot.setInteraction(QCP.iSelectPlottables) | |
79 | + | |
80 | +window.show() | |
81 | +sys.exit(app.exec_()) | |
67 | 82 | ``` |
68 | 83 | |
69 | 84 | That's all! |