本文整理汇总了Python中silx.gui.plot.PlotWindow.addDockWidget方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow.addDockWidget方法的具体用法?Python PlotWindow.addDockWidget怎么用?Python PlotWindow.addDockWidget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.addDockWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestRegionOfInterestManager
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import addDockWidget [as 别名]
class TestRegionOfInterestManager(TestCaseQt, ParametricTestCase):
"""Tests for RegionOfInterestManager class"""
def setUp(self):
super(TestRegionOfInterestManager, self).setUp()
self.plot = PlotWindow()
self.roiTableWidget = roi.RegionOfInterestTableWidget()
dock = qt.QDockWidget()
dock.setWidget(self.roiTableWidget)
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
del self.roiTableWidget
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestRegionOfInterestManager, self).tearDown()
def test(self):
"""Test ROI of different shapes"""
tests = ( # shape, points=[list of (x, y), list of (x, y)]
(roi_items.PointROI, numpy.array(([(10., 15.)], [(20., 25.)]))),
(roi_items.RectangleROI,
numpy.array((((1., 10.), (11., 20.)),
((2., 3.), (12., 13.))))),
(roi_items.PolygonROI,
numpy.array((((0., 1.), (0., 10.), (10., 0.)),
((5., 6.), (5., 16.), (15., 6.))))),
(roi_items.LineROI,
numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
(roi_items.HorizontalLineROI,
numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
(roi_items.VerticalLineROI,
numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
)
for roiClass, points in tests:
with self.subTest(roiClass=roiClass):
manager = roi.RegionOfInterestManager(self.plot)
self.roiTableWidget.setRegionOfInterestManager(manager)
manager.start(roiClass)
self.assertEqual(manager.getRois(), ())
finishListener = SignalListener()
manager.sigInteractiveModeFinished.connect(finishListener)
changedListener = SignalListener()
manager.sigRoiChanged.connect(changedListener)
# Add a point
manager.createRoi(roiClass, points[0])
self.qapp.processEvents()
self.assertTrue(len(manager.getRois()), 1)
self.assertEqual(changedListener.callCount(), 1)
# Remove it
manager.removeRoi(manager.getRois()[0])
self.assertEqual(manager.getRois(), ())
self.assertEqual(changedListener.callCount(), 2)
# Add two point
manager.createRoi(roiClass, points[0])
self.qapp.processEvents()
manager.createRoi(roiClass, points[1])
self.qapp.processEvents()
self.assertTrue(len(manager.getRois()), 2)
self.assertEqual(changedListener.callCount(), 4)
# Reset it
result = manager.clear()
self.assertTrue(result)
self.assertEqual(manager.getRois(), ())
self.assertEqual(changedListener.callCount(), 5)
changedListener.clear()
# Add two point
manager.createRoi(roiClass, points[0])
self.qapp.processEvents()
manager.createRoi(roiClass, points[1])
self.qapp.processEvents()
self.assertTrue(len(manager.getRois()), 2)
self.assertEqual(changedListener.callCount(), 2)
# stop
result = manager.stop()
self.assertTrue(result)
self.assertTrue(len(manager.getRois()), 1)
self.qapp.processEvents()
self.assertEqual(finishListener.callCount(), 1)
#.........这里部分代码省略.........
示例2: TestMaskToolsWidget
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import addDockWidget [as 别名]
class TestMaskToolsWidget(TestCaseQt):
"""Basic test for MaskToolsWidget"""
def setUp(self):
super(TestMaskToolsWidget, self).setUp()
self.plot = PlotWindow()
self.widget = MaskToolsWidget.MaskToolsDockWidget(self.plot, 'TEST')
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, self.widget)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.maskWidget = self.widget.widget()
def tearDown(self):
del self.maskWidget
del self.widget
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestMaskToolsWidget, self).tearDown()
def testEmptyPlot(self):
"""Empty plot, display MaskToolsDockWidget, toggle multiple masks"""
self.maskWidget.setMultipleMasks('single')
self.qapp.processEvents()
self.maskWidget.setMultipleMasks('exclusive')
self.qapp.processEvents()
def _drag(self):
"""Drag from plot center to offset position"""
plot = self.plot.centralWidget()
xCenter, yCenter = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
pos0 = xCenter, yCenter
pos1 = xCenter + offset, yCenter + offset
self.mouseMove(plot, pos=pos0)
self.mousePress(plot, qt.Qt.LeftButton, pos=pos0)
self.mouseMove(plot, pos=pos1)
self.mouseRelease(plot, qt.Qt.LeftButton, pos=pos1)
def _drawPolygon(self):
"""Draw a star polygon in the plot"""
plot = self.plot.centralWidget()
x, y = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
star = [(x, y + offset),
(x - offset, y - offset),
(x + offset, y),
(x - offset, y),
(x + offset, y - offset)]
for pos in star:
self.mouseMove(plot, pos=pos)
btn = qt.Qt.LeftButton if pos != star[-1] else qt.Qt.RightButton
self.mouseClick(plot, btn, pos=pos)
def _drawPencil(self):
"""Draw a star polygon in the plot"""
plot = self.plot.centralWidget()
x, y = plot.width() // 2, plot.height() // 2
offset = min(plot.width(), plot.height()) // 10
star = [(x, y + offset),
(x - offset, y - offset),
(x + offset, y),
(x - offset, y),
(x + offset, y - offset)]
self.mouseMove(plot, pos=star[0])
self.mousePress(plot, qt.Qt.LeftButton, pos=star[0])
for pos in star:
self.mouseMove(plot, pos=pos)
self.mouseRelease(
plot, qt.Qt.LeftButton, pos=star[-1])
def testWithAnImage(self):
"""Plot with an image: test MaskToolsWidget interactions"""
# Add and remove a image (this should enable/disable GUI + change mask)
self.plot.addImage(numpy.random.random(1024**2).reshape(1024, 1024),
legend='test')
self.qapp.processEvents()
self.plot.remove('test', kind='image')
self.qapp.processEvents()
self.plot.addImage(numpy.arange(1024**2).reshape(1024, 1024),
legend='test')
self.qapp.processEvents()
# Test draw rectangle #
toolButton = getQToolButtonFromAction(self.maskWidget.rectAction)
#.........这里部分代码省略.........
示例3: TestRegionOfInterestManager
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import addDockWidget [as 别名]
class TestRegionOfInterestManager(TestCaseQt, ParametricTestCase):
"""Tests for RegionOfInterestManager class"""
def setUp(self):
super(TestRegionOfInterestManager, self).setUp()
self.plot = PlotWindow()
self.roiTableWidget = roi.RegionOfInterestTableWidget()
dock = qt.QDockWidget()
dock.setWidget(self.roiTableWidget)
self.plot.addDockWidget(qt.Qt.BottomDockWidgetArea, dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
del self.roiTableWidget
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestRegionOfInterestManager, self).tearDown()
def test(self):
"""Test ROI of different shapes"""
tests = ( # shape, points=[list of (x, y), list of (x, y)]
('point', numpy.array(([(10., 15.)], [(20., 25.)]))),
('rectangle', numpy.array((((1., 10.), (11., 20.)),
((2., 3.), (12., 13.))))),
('polygon', numpy.array((((0., 1.), (0., 10.), (10., 0.)),
((5., 6.), (5., 16.), (15., 6.))))),
('line', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
('hline', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
('vline', numpy.array((((10., 20.), (10., 30.)),
((30., 40.), (30., 50.))))),
)
for kind, points in tests:
with self.subTest(kind=kind):
manager = roi.RegionOfInterestManager(self.plot)
self.roiTableWidget.setRegionOfInterestManager(manager)
manager.start(kind)
self.assertEqual(manager.getRegionOfInterests(), ())
finishListener = SignalListener()
manager.sigInteractiveModeFinished.connect(finishListener)
changedListener = SignalListener()
manager.sigRegionOfInterestChanged.connect(changedListener)
# Add a point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(), (points[0],))))
self.assertEqual(changedListener.callCount(), 1)
# Remove it
manager.removeRegionOfInterest(manager.getRegionOfInterests()[0])
self.assertEqual(manager.getRegionOfInterests(), ())
self.assertEqual(changedListener.callCount(), 2)
# Add two point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
manager.createRegionOfInterest(kind, points[1])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
self.assertEqual(changedListener.callCount(), 4)
# Reset it
result = manager.clearRegionOfInterests()
self.assertTrue(result)
self.assertEqual(manager.getRegionOfInterests(), ())
self.assertEqual(changedListener.callCount(), 5)
changedListener.clear()
# Add two point
manager.createRegionOfInterest(kind, points[0])
self.qapp.processEvents()
manager.createRegionOfInterest(kind, points[1])
self.qapp.processEvents()
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
self.assertEqual(changedListener.callCount(), 2)
# stop
result = manager.stop()
self.assertTrue(result)
self.assertTrue(numpy.all(numpy.equal(
manager.getRegionOfInterestPoints(),
(points[0], points[1]))))
#.........这里部分代码省略.........