Skip to content

Commit 03683a5

Browse files
author
Luke Campagnola
committed
Bugfixes:
- ArrowItem auto range now works correctly - Dock drag/drop fixed on PySide - Made padding behavior consistent across ViewBox methods - Fixed MeshData / python2.6 incompatibility - Fixed ScatterPlotItem.setSize and .setPointData - Workaround for PySide bug; GradientEditor fixed - Prefer initially selecting PlotItem rather then ViewBox when exporting - Fixed python3 import error with flowcharts Cleaned up examples, made code editable from example loader Minor documentation updates
2 parents 2e79185 + 4cf9ef7 commit 03683a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+597
-202
lines changed

doc/source/how_to_use.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Pyqtgraph makes it very easy to visualize data from the command line. Observe::
1717
import pyqtgraph as pg
1818
pg.plot(data) # data can be a list of values or a numpy array
1919

20-
The example above would open a window displaying a line plot of the data given. The call to :func:`pg.plot <pyqtgraph.plot>` returns a handle to the :class:`plot widget <pyqtgraph.PlotWidget>` that is created, allowing more data to be added to the same window.
20+
The example above would open a window displaying a line plot of the data given. The call to :func:`pg.plot <pyqtgraph.plot>` returns a handle to the :class:`plot widget <pyqtgraph.PlotWidget>` that is created, allowing more data to be added to the same window. **Note:** interactive plotting from the python prompt is only available with PyQt; PySide does not run the Qt event loop while the interactive prompt is running. If you wish to use pyqtgraph interactively with PySide, see the 'console' :ref:`example <examples>`.
2121

2222
Further examples::
2323

doc/source/qtcrashcourse.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ Signals, Slots, and Events
6666

6767
[ to be continued.. please post a request on the pyqtgraph forum if you'd like to read more ]
6868

69+
Qt detects and reacts to user interaction by executing its *event loop*.
70+
71+
- what happens in the event loop?
72+
- when do I need to use QApplication.exec_() ?
73+
- what control do I have over event loop execution? (QApplication.processEvents)
74+
6975

7076
GraphicsView and GraphicsItems
7177
------------------------------
@@ -79,8 +85,8 @@ Mouse and Keyboard Input
7985
------------------------
8086

8187

82-
QTimer, the Event Loop, and Multi-Threading
83-
-------------------------------------------
88+
QTimer, Multi-Threading
89+
-----------------------
8490

8591

8692
Multi-threading vs Multi-processing in Qt

examples/Arrow.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
Display an animated arrowhead following a curve.
4+
This example uses the CurveArrow class, which is a combination
5+
of ArrowItem and CurvePoint.
26
3-
## Display an animated arrowhead following a curve.
4-
## This example uses the CurveArrow class, which is a combination
5-
## of ArrowItem and CurvePoint.
6-
##
7-
## To place a static arrow anywhere in a scene, use ArrowItem.
8-
## To attach other types of item to a curve, use CurvePoint.
7+
To place a static arrow anywhere in a scene, use ArrowItem.
8+
To attach other types of item to a curve, use CurvePoint.
9+
"""
910

1011
import initExample ## Add path to library (just for examples; you do not need this)
1112

@@ -21,6 +22,7 @@
2122
w.show()
2223
w.resize(400,600)
2324
w.setCentralWidget(cw)
25+
w.setWindowTitle('pyqtgraph example: Arrow')
2426

2527
p = cw.addPlot(row=0, col=0)
2628
p2 = cw.addPlot(row=1, col=0)

examples/CLIexample.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1+
"""
2+
Display a plot and an image with minimal setup.
3+
4+
pg.plot() and pg.image() are indended to be used from an interactive prompt
5+
to allow easy data inspection (but note that PySide unfortunately does not
6+
call the Qt event loop while the interactive prompt is running, in this case
7+
it is necessary to call QApplication.exec_() to make the windows appear).
8+
"""
19
import initExample ## Add path to library (just for examples; you do not need this)
210

3-
from pyqtgraph.Qt import QtGui, QtCore
11+
412
import numpy as np
513
import pyqtgraph as pg
614

7-
app = QtGui.QApplication([])
8-
9-
1015
data = np.random.normal(size=1000)
1116
pg.plot(data, title="Simplest possible plotting example")
1217

1318
data = np.random.normal(size=(500,500))
14-
pg.show(data, title="Simplest possible image example")
19+
pg.image(data, title="Simplest possible image example")
1520

1621

1722
## Start Qt event loop unless running in interactive mode or using pyside.
1823
if __name__ == '__main__':
1924
import sys
2025
if sys.flags.interactive != 1 or not hasattr(QtCore, 'PYQT_VERSION'):
21-
app.exec_()
26+
pg.QtGui.QApplication.exec_()

examples/ColorButton.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# -*- coding: utf-8 -*-
2-
import initExample ## Add path to library (just for examples; you do not need this)
3-
42
"""
53
Simple example demonstrating a button which displays a colored rectangle
64
and allows the user to select a new color by clicking on the button.
75
"""
86

7+
import initExample ## Add path to library (just for examples; you do not need this)
8+
9+
910
import pyqtgraph as pg
1011
from pyqtgraph.Qt import QtCore, QtGui
1112
import numpy as np
@@ -15,6 +16,7 @@
1516
btn = pg.ColorButton()
1617
win.setCentralWidget(btn)
1718
win.show()
19+
win.setWindowTitle('pyqtgraph example: ColorButton')
1820

1921
def change(btn):
2022
print("change", btn.color())

examples/ConsoleWidget.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
ConsoleWidget is used to allow execution of user-supplied python commands
4+
in an application. It also includes a command history and functionality for trapping
5+
and inspecting stack traces.
6+
7+
"""
28
import initExample ## Add path to library (just for examples; you do not need this)
39

410
import pyqtgraph as pg
@@ -21,6 +27,7 @@
2127
"""
2228
c = pyqtgraph.console.ConsoleWidget(namespace=namespace, text=text)
2329
c.show()
30+
c.setWindowTitle('pyqtgraph example: ConsoleWidget')
2431

2532
## Start Qt event loop unless running in interactive mode or using pyside.
2633
if __name__ == '__main__':

examples/DataSlicing.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
Demonstrate a simple data-slicing task: given 3D data (displayed at top), select
4+
a 2D plane and interpolate data along that plane to generate a slice image
5+
(displayed at bottom).
6+
7+
8+
"""
9+
210
## Add path to library (just for examples; you do not need this)
311
import initExample
412

@@ -12,6 +20,7 @@
1220
## Create window with two ImageView widgets
1321
win = QtGui.QMainWindow()
1422
win.resize(800,800)
23+
win.setWindowTitle('pyqtgraph example: DataSlicing')
1524
cw = QtGui.QWidget()
1625
win.setCentralWidget(cw)
1726
l = QtGui.QGridLayout()

examples/DataTreeWidget.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Simple use of DataTreeWidget to display a structure of nested dicts, lists, and arrays
55
"""
66

7-
8-
97
import initExample ## Add path to library (just for examples; you do not need this)
108

119
import pyqtgraph as pg
@@ -26,6 +24,7 @@
2624

2725
tree = pg.DataTreeWidget(data=d)
2826
tree.show()
27+
tree.setWindowTitle('pyqtgraph example: DataTreeWidget')
2928
tree.resize(600,600)
3029

3130

examples/Draw.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# -*- coding: utf-8 -*-
2+
"""
3+
Demonstrate ability of ImageItem to be used as a canvas for painting with
4+
the mouse.
5+
6+
"""
7+
28
import initExample ## Add path to library (just for examples; you do not need this)
39

410

@@ -12,6 +18,7 @@
1218
w = pg.GraphicsView()
1319
w.show()
1420
w.resize(800,800)
21+
w.setWindowTitle('pyqtgraph example: Draw')
1522

1623
view = pg.ViewBox()
1724
w.setCentralItem(view)

examples/ErrorBarItem.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
bottom = np.linspace(2, 0.5, 10)
2222

2323
plt = pg.plot()
24+
plt.setWindowTitle('pyqtgraph example: ErrorBarItem')
2425
err = pg.ErrorBarItem(x=x, y=y, top=top, bottom=bottom, beam=0.5)
2526
plt.addItem(err)
2627
plt.plot(x, y, symbol='o', pen={'color': 0.8, 'width': 2})

0 commit comments

Comments
 (0)