本文整理汇总了Python中silx.gui.plot.PlotWindow.width方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow.width方法的具体用法?Python PlotWindow.width怎么用?Python PlotWindow.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.width方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestPositionInfo
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import width [as 别名]
class TestPositionInfo(TestCaseQt):
"""Tests for PositionInfo widget."""
def setUp(self):
super(TestPositionInfo, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
def tearDown(self):
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestPositionInfo, self).tearDown()
def _test(self, positionWidget, converterNames):
"""General test of PositionInfo.
- Add it to a toolbar and
- Move mouse around the center of the PlotWindow.
"""
toolBar = qt.QToolBar()
self.plot.addToolBar(qt.Qt.BottomToolBarArea, toolBar)
toolBar.addWidget(positionWidget)
converters = positionWidget.getConverters()
self.assertEqual(len(converters), len(converterNames))
for index, name in enumerate(converterNames):
self.assertEqual(converters[index][0], name)
# Move mouse away from center
xCenter, yCenter = self.plot.width() // 2, self.plot.height() // 2
self.mouseMove(self.plot, pos=(xCenter + 1, yCenter + 1))
self.qapp.processEvents()
def testDefaultConverters(self):
"""Test PositionInfo with default converters"""
positionWidget = PlotTools.PositionInfo(self.plot)
self._test(positionWidget, ('X', 'Y'))
def testCustomConverters(self):
"""Test PositionInfo with custom converters"""
positionWidget = PlotTools.PositionInfo(self.plot, converters=[
('Coords', lambda x, y: (int(x), int(y))),
('Radius', lambda x, y: numpy.sqrt(x*x + y*y)),
('Angle', lambda x, y: numpy.degrees(numpy.arctan2(y, x)))])
self._test(positionWidget, ('Coords', 'Radius', 'Angle'))
@test_logging(PlotTools.__name__, error=2)
def testFailingConverters(self):
"""Test PositionInfo with failing custom converters"""
def raiseException(x, y):
raise RuntimeError()
positionWidget = PlotTools.PositionInfo(
self.plot, converters=[('Exception', raiseException)])
self._test(positionWidget, ['Exception'])