本文整理匯總了Python中silx.gui.plot.PlotWindow.height方法的典型用法代碼示例。如果您正苦於以下問題:Python PlotWindow.height方法的具體用法?Python PlotWindow.height怎麽用?Python PlotWindow.height使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.height方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestPositionInfo
# 需要導入模塊: from silx.gui.plot import PlotWindow [as 別名]
# 或者: from silx.gui.plot.PlotWindow import height [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'])