Skip to content

Commit 2db6dcf

Browse files
committed
Fixed simple plot examples (setup.py & plot.py's doc page)
following the introduction of QtPy since V0.8.0 This closes #55
1 parent 534024e commit 2db6dcf

File tree

6 files changed

+29
-19
lines changed

6 files changed

+29
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# PythonQwt Releases #
22

3+
### Version 0.8.3 ###
4+
5+
- Fixed simple plot example (setup.py & plot.py's doc page) following the introduction
6+
of the new QtPy dependency (Qt compatibility layer) since V0.8.0.
7+
38
### Version 0.8.2 ###
49

510
- Added new GUI-based test script `PythonQwt-py3` to run the test launcher.

doc/plot_example.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
from qtpy import QtWidgets as QW
12
import qwt
23
import numpy as np
34

4-
app = qtpy.QtGui.QApplication([])
5+
app = QW.QApplication([])
56
x = np.linspace(-10, 10, 500)
67
plot = qwt.QwtPlot("Trigonometric functions")
78
plot.insertLegend(qwt.QwtLegend(), qwt.QwtPlot.BottomLegend)

doc/symbol_path_example.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,47 @@
1-
from qtpy.QtGui import QApplication, QPen, QPainterPath, QTransform
2-
from qtpy.QtCore import Qt, QPointF
3-
from qwt import QwtPlot, QwtPlotCurve, QwtSymbol
1+
from qtpy import QtWidgets as QW
2+
from qtpy import QtGui as QG
3+
from qtpy import QtCore as QC
4+
import qwt
45
import numpy as np
56
import os.path as osp
67

7-
app = QApplication([])
8+
app = QW.QApplication([])
89

910
# --- Construct custom symbol ---
1011

11-
path = QPainterPath()
12+
path = QG.QPainterPath()
1213
path.moveTo(0, 8)
1314
path.lineTo(0, 5)
1415
path.lineTo(-3, 5)
1516
path.lineTo(0, 0)
1617
path.lineTo(3, 5)
1718
path.lineTo(0, 5)
1819

19-
transform = QTransform()
20+
transform = QG.QTransform()
2021
transform.rotate(-30.0)
2122
path = transform.map(path)
2223

23-
pen = QPen(Qt.black, 2)
24-
pen.setJoinStyle(Qt.MiterJoin)
24+
pen = QG.QPen(QC.Qt.black, 2)
25+
pen.setJoinStyle(QC.Qt.MiterJoin)
2526

26-
symbol = QwtSymbol()
27+
symbol = qwt.QwtSymbol()
2728
symbol.setPen(pen)
28-
symbol.setBrush(Qt.red)
29+
symbol.setBrush(QC.Qt.red)
2930
symbol.setPath(path)
30-
symbol.setPinPoint(QPointF(0.0, 0.0))
31+
symbol.setPinPoint(QC.QPointF(0.0, 0.0))
3132
symbol.setSize(10, 14)
3233

3334
# --- Test it within a simple plot ---
3435

35-
curve = QwtPlotCurve()
36-
curve_pen = QPen(Qt.blue)
37-
curve_pen.setStyle(Qt.DotLine)
36+
curve = qwt.QwtPlotCurve()
37+
curve_pen = QG.QPen(QC.Qt.blue)
38+
curve_pen.setStyle(QC.Qt.DotLine)
3839
curve.setPen(curve_pen)
3940
curve.setSymbol(symbol)
4041
x = np.linspace(0, 10, 10)
4142
curve.setData(x, np.sin(x))
4243

43-
plot = QwtPlot()
44+
plot = qwt.QwtPlot()
4445
curve.attach(plot)
4546
plot.resize(600, 300)
4647
plot.replot()

qwt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
.. _GitHubPage: http://pierreraybaut.github.io/PythonQwt
2929
.. _GitHub: https://github.com/PierreRaybaut/PythonQwt
3030
"""
31-
__version__ = "0.8.2"
31+
__version__ = "0.8.3"
3232
QWT_VERSION_STR = "6.1.5"
3333

3434
import warnings

qwt/plot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,11 @@ class QwtPlot(QFrame, QwtPlotDict):
234234
The following example is a good starting point to see how to set up a
235235
plot widget::
236236
237+
from qtpy import QtWidgets as QW
237238
import qwt
238239
import numpy as np
239240
240-
app = qtpy.QtGui.QApplication([])
241+
app = QW.QApplication([])
241242
x = np.linspace(-10, 10, 500)
242243
plot = qwt.QwtPlot("Trigonometric functions")
243244
plot.insertLegend(qwt.QwtLegend(), qwt.QwtPlot.BottomLegend)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,19 @@
5151
5252
The following example is a good starting point to see how to set up a simple plot widget::
5353
54+
from qtpy import QtWidgets as QW
5455
import qwt
5556
import numpy as np
5657
57-
app = qtpy.QtGui.QApplication([])
58+
app = QW.QApplication([])
5859
x = np.linspace(-10, 10, 500)
5960
plot = qwt.QwtPlot("Trigonometric functions")
6061
plot.insertLegend(qwt.QwtLegend(), qwt.QwtPlot.BottomLegend)
6162
qwt.QwtPlotCurve.make(x, np.cos(x), "Cosinus", plot, linecolor="red", antialiased=True)
6263
qwt.QwtPlotCurve.make(x, np.sin(x), "Sinus", plot, linecolor="blue", antialiased=True)
6364
plot.resize(600, 300)
6465
plot.show()
66+
app.exec_()
6567
6668
.. image:: https://raw.githubusercontent.com/PierreRaybaut/PythonQwt/master/doc/images/QwtPlot_example.png
6769

0 commit comments

Comments
 (0)