TST: But I should not just copy/paste code...
This commit is contained in:
parent
94e457885c
commit
cb326c4fd7
|
@ -3,6 +3,7 @@ import pyqtgraph as pg
|
||||||
|
|
||||||
app = pg.mkQApp()
|
app = pg.mkQApp()
|
||||||
qtest = pg.Qt.QtTest.QTest
|
qtest = pg.Qt.QtTest.QTest
|
||||||
|
QRectF = pg.QtCore.QRectF
|
||||||
|
|
||||||
def assertMapping(vb, r1, r2):
|
def assertMapping(vb, r1, r2):
|
||||||
assert vb.mapFromView(r1.topLeft()) == r2.topLeft()
|
assert vb.mapFromView(r1.topLeft()) == r2.topLeft()
|
||||||
|
@ -10,9 +11,10 @@ def assertMapping(vb, r1, r2):
|
||||||
assert vb.mapFromView(r1.topRight()) == r2.topRight()
|
assert vb.mapFromView(r1.topRight()) == r2.topRight()
|
||||||
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
|
assert vb.mapFromView(r1.bottomRight()) == r2.bottomRight()
|
||||||
|
|
||||||
def test_ViewBox():
|
def init_viewbox():
|
||||||
global app, win, vb
|
"""Helper function to init the ViewBox
|
||||||
QRectF = pg.QtCore.QRectF
|
"""
|
||||||
|
global win, vb
|
||||||
|
|
||||||
win = pg.GraphicsWindow()
|
win = pg.GraphicsWindow()
|
||||||
win.ci.layout.setContentsMargins(0,0,0,0)
|
win.ci.layout.setContentsMargins(0,0,0,0)
|
||||||
|
@ -31,6 +33,9 @@ def test_ViewBox():
|
||||||
|
|
||||||
app.processEvents()
|
app.processEvents()
|
||||||
|
|
||||||
|
def test_ViewBox():
|
||||||
|
init_viewbox()
|
||||||
|
|
||||||
w = vb.geometry().width()
|
w = vb.geometry().width()
|
||||||
h = vb.geometry().height()
|
h = vb.geometry().height()
|
||||||
view1 = QRectF(0, 0, 10, 10)
|
view1 = QRectF(0, 0, 10, 10)
|
||||||
|
@ -68,25 +73,7 @@ def test_ViewBox():
|
||||||
|
|
||||||
|
|
||||||
def test_limits_and_resize():
|
def test_limits_and_resize():
|
||||||
global app, win, vb
|
init_viewbox()
|
||||||
QRectF = pg.QtCore.QRectF
|
|
||||||
|
|
||||||
win = pg.GraphicsWindow()
|
|
||||||
win.ci.layout.setContentsMargins(0,0,0,0)
|
|
||||||
win.resize(200, 200)
|
|
||||||
win.show()
|
|
||||||
vb = win.addViewBox()
|
|
||||||
|
|
||||||
# set range before viewbox is shown
|
|
||||||
vb.setRange(xRange=[0, 10], yRange=[0, 10], padding=0)
|
|
||||||
|
|
||||||
# required to make mapFromView work properly.
|
|
||||||
qtest.qWaitForWindowShown(win)
|
|
||||||
|
|
||||||
g = pg.GridItem()
|
|
||||||
vb.addItem(g)
|
|
||||||
|
|
||||||
app.processEvents()
|
|
||||||
|
|
||||||
# now lock aspect
|
# now lock aspect
|
||||||
vb.setAspectLocked()
|
vb.setAspectLocked()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user