本文整理汇总了Python中silx.gui.plot.PlotWidget.setAttribute方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.setAttribute方法的具体用法?Python PlotWidget.setAttribute怎么用?Python PlotWidget.setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.setAttribute方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestNamedScatterAlphaSlider
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setAttribute [as 别名]
class TestNamedScatterAlphaSlider(TestCaseQt):
def setUp(self):
super(TestNamedScatterAlphaSlider, self).setUp()
self.plot = PlotWidget()
self.aslider = AlphaSlider.NamedScatterAlphaSlider(plot=self.plot)
self.aslider.setOrientation(qt.Qt.Horizontal)
toolbar = qt.QToolBar("plot", self.plot)
toolbar.addWidget(self.aslider)
self.plot.addToolBar(toolbar)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
del self.aslider
super(TestNamedScatterAlphaSlider, self).tearDown()
def testWidgetEnabled(self):
# no Scatter set initially, slider must be deactivate
self.assertFalse(self.aslider.isEnabled())
self.plot.addScatter([0, 1, 2], [2, 3, 4], [5, 6, 7],
legend="1")
self.aslider.setLegend("1")
# now we have an image set
self.assertTrue(self.aslider.isEnabled())
def testGetScatter(self):
self.plot.addScatter([0, 1, 2], [2, 3, 4], [5, 6, 7],
legend="1")
self.plot.addScatter([0, 10, 20], [20, 30, 40], [50, 60, 70],
legend="2")
self.aslider.setLegend("1")
self.assertEqual(self.plot.getScatter("1"),
self.aslider.getItem())
self.aslider.setLegend("2")
self.assertEqual(self.plot.getScatter("2"),
self.aslider.getItem())
def testGetAlpha(self):
self.plot.addScatter([0, 10, 20], [20, 30, 40], [50, 60, 70],
legend="1")
self.aslider.setLegend("1")
self.aslider.setValue(128)
self.assertAlmostEqual(self.aslider.getAlpha(),
128. / 255)
示例2: TestActiveImageAlphaSlider
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setAttribute [as 别名]
class TestActiveImageAlphaSlider(TestCaseQt):
def setUp(self):
super(TestActiveImageAlphaSlider, self).setUp()
self.plot = PlotWidget()
self.aslider = AlphaSlider.ActiveImageAlphaSlider(plot=self.plot)
self.aslider.setOrientation(qt.Qt.Horizontal)
toolbar = qt.QToolBar("plot", self.plot)
toolbar.addWidget(self.aslider)
self.plot.addToolBar(toolbar)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
del self.aslider
super(TestActiveImageAlphaSlider, self).tearDown()
def testWidgetEnabled(self):
# no active image initially, slider must be deactivate
self.assertFalse(self.aslider.isEnabled())
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]))
# now we have an active image
self.assertTrue(self.aslider.isEnabled())
self.plot.setActiveImage(None)
self.assertFalse(self.aslider.isEnabled())
def testGetImage(self):
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]))
self.assertEqual(self.plot.getActiveImage(),
self.aslider.getItem())
self.plot.addImage(numpy.array([[0, 1, 3], [2, 4, 6]]), legend="2")
self.plot.setActiveImage("2")
self.assertEqual(self.plot.getImage("2"),
self.aslider.getItem())
def testGetAlpha(self):
self.plot.addImage(numpy.array([[0, 1, 2], [3, 4, 5]]), legend="1")
self.aslider.setValue(137)
self.assertAlmostEqual(self.aslider.getAlpha(),
137. / 255)
示例3: _PlotWidgetTest
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import setAttribute [as 别名]
class _PlotWidgetTest(TestCaseQt):
"""Base class for tests of PlotWidget, not a TestCase in itself.
plot attribute is the PlotWidget created for the test.
"""
def setUp(self):
super(_PlotWidgetTest, self).setUp()
self.plot = PlotWidget()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(_PlotWidgetTest, self).tearDown()