本文整理汇总了Python中silx.gui.plot.PlotWindow类的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow类的具体用法?Python PlotWindow怎么用?Python PlotWindow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PlotWindow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestCurvesROIWidget
class TestCurvesROIWidget(TestCaseQt):
"""Basic test for CurvesROIWidget"""
def setUp(self):
super(TestCurvesROIWidget, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.widget = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST')
self.widget.show()
self.qWaitForWindowExposed(self.widget)
def tearDown(self):
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
self.widget.setAttribute(qt.Qt.WA_DeleteOnClose)
self.widget.close()
del self.widget
super(TestCurvesROIWidget, self).tearDown()
def testEmptyPlot(self):
"""Empty plot, display ROI widget"""
pass
def testWithCurves(self):
"""Plot with curves: test all ROI widget buttons"""
for offset in range(2):
self.plot.addCurve(numpy.arange(1000),
offset + numpy.random.random(1000),
legend=str(offset))
# Add two ROI
self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
self.mouseClick(self.widget.roiWidget.addButton, qt.Qt.LeftButton)
# Change active curve
self.plot.setActiveCurve(str(1))
# Delete a ROI
self.mouseClick(self.widget.roiWidget.delButton, qt.Qt.LeftButton)
with temp_dir() as tmpDir:
self.tmpFile = os.path.join(tmpDir, 'test.ini')
# Save ROIs
self.widget.roiWidget.save(self.tmpFile)
self.assertTrue(os.path.isfile(self.tmpFile))
# Reset ROIs
self.mouseClick(self.widget.roiWidget.resetButton,
qt.Qt.LeftButton)
# Load ROIs
self.widget.roiWidget.load(self.tmpFile)
del self.tmpFile
示例2: setUp
def setUp(self):
super(TestProfileToolBar, self).setUp()
profileWindow = PlotWindow()
self.plot = PlotWindow()
self.toolBar = Profile.ProfileToolBar(
plot=self.plot, profileWindow=profileWindow)
self.plot.addToolBar(self.toolBar)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
profileWindow.show()
self.qWaitForWindowExposed(profileWindow)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
示例3: setUp
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()
示例4: setUp
def setUp(self):
super(TestCurvesROIWidget, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.widget = CurvesROIWidget.CurvesROIDockWidget(plot=self.plot, name='TEST')
self.widget.show()
self.qWaitForWindowExposed(self.widget)
示例5: setUp
def setUp(self):
super(TestScatterProfileToolBar, self).setUp()
self.plot = PlotWindow()
self.profile = profile.ScatterProfileToolBar(plot=self.plot)
self.plot.addToolBar(self.profile)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
示例6: setUp
def setUp(self):
super(TestCurvesROIWidget, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
self.widget = self.plot.getCurvesRoiDockWidget()
self.widget.show()
self.qWaitForWindowExposed(self.widget)
示例7: __init__
def __init__(self, parent=None, initdict = None):
qt.QWidget.__init__(self, parent)
self.l = qt.QVBoxLayout(self)
self.l.setContentsMargins(0, 0, 0, 0)
self.l.setSpacing(0)
self.tubeWidget = TubeWidget(self, initdict = initdict)
self.setParameters = self.tubeWidget.setParameters
self.getParameters = self.tubeWidget.getParameters
label = qt.QLabel(self)
hbox = qt.QWidget(self)
hboxl = qt.QHBoxLayout(hbox)
hboxl.setContentsMargins(0, 0, 0, 0)
hboxl.setSpacing(0)
self.plotButton = qt.QPushButton(hbox)
self.plotButton.setText("Plot Continuum")
self.exportButton = qt.QPushButton(hbox)
self.exportButton.setText("Export to Fit")
#grid.addWidget(self.plotButton, 7, 1)
#grid.addWidget(self.exportButton, 7, 3)
hboxl.addWidget(self.plotButton)
hboxl.addWidget(self.exportButton)
self.l.addWidget(self.tubeWidget)
f = label.font()
f.setItalic(1)
label.setFont(f)
label.setAlignment(qt.Qt.AlignRight)
label.setText("H. Ebel, X-Ray Spectrometry 28 (1999) 255-266 ")
self.l.addWidget(label)
self.l.addWidget(hbox)
self.graph = PlotWindow(self, colormap=False, yInverted=False,
aspectRatio=False, control=False,
position=False, roi=False, mask=False,
fit=False)
self.pluginsToolButton = PluginsToolButton(plot=self.graph)
self.graph.toolBar().addWidget(self.pluginsToolButton)
self.graph.getInteractiveModeToolBar().getZoomModeAction().setVisible(False)
self.graph.getInteractiveModeToolBar().getPanModeAction().setVisible(False)
self.l.addWidget(self.graph)
self.graph.setGraphXLabel("Energy (keV)")
self.graph.setGraphYLabel("photons/sr/mA/keV/s")
self.plotButton.clicked.connect(self.plot)
self.exportButton.clicked.connect(self._export)
示例8: setUp
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()
示例9: setUp
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)
示例10: TestPlotWindow
class TestPlotWindow(TestCaseQt):
"""Base class for tests of PlotWindow."""
def setUp(self):
super(TestPlotWindow, self).setUp()
self.plot = PlotWindow()
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestPlotWindow, self).tearDown()
def testActions(self):
"""Test the actions QToolButtons"""
self.plot.setLimits(1, 100, 1, 100)
checkList = [ # QAction, Plot state getter
(self.plot.xAxisAutoScaleAction, self.plot.isXAxisAutoScale),
(self.plot.yAxisAutoScaleAction, self.plot.isYAxisAutoScale),
(self.plot.xAxisLogarithmicAction, self.plot.isXAxisLogarithmic),
(self.plot.yAxisLogarithmicAction, self.plot.isYAxisLogarithmic),
(self.plot.gridAction, self.plot.getGraphGrid),
(self.plot.keepDataAspectRatioAction,
self.plot.isKeepDataAspectRatio),
(self.plot.yAxisInvertedAction, self.plot.isYAxisInverted),
]
for action, getter in checkList:
self.mouseMove(self.plot)
initialState = getter()
toolButton = getQToolButtonFromAction(action)
self.assertIsNot(toolButton, None)
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.assertNotEqual(getter(), initialState,
msg='"%s" state not changed' % action.text())
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.assertEqual(getter(), initialState,
msg='"%s" state not changed' % action.text())
# Trigger a zoom reset
self.mouseMove(self.plot)
resetZoomAction = self.plot.resetZoomAction
toolButton = getQToolButtonFromAction(resetZoomAction)
self.assertIsNot(toolButton, None)
self.mouseClick(toolButton, qt.Qt.LeftButton)
示例11: setUp
def setUp(self):
super(TestCurveLegendsWidget, self).setUp()
self.plot = PlotWindow()
self.legends = CurveLegendsWidget.CurveLegendsWidget()
self.legends.setPlotWidget(self.plot)
dock = qt.QDockWidget()
dock.setWindowTitle('Curve Legends')
dock.setWidget(self.legends)
self.plot.addTabbedDockWidget(dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
示例12: __init__
def __init__(self, parent=None, backend=None):
super(RateLawMdiArea, self).__init__(parent)
self._windowDict = {}
self._windowList = ["Original", "Zero",
"First", "Second"]
self._windowList.reverse()
for title in self._windowList:
plot = PlotWindow(self,
position=True, backend=backend,
colormap=False, aspectRatio=False,
yInverted=False, roi=False, mask=False)
self.pluginsToolButton = PluginsToolButton(plot=plot)
plot.toolBar().addWidget(self.pluginsToolButton)
plot.setWindowTitle(title)
self.addSubWindow(plot)
self._windowDict[title] = plot
plot.setDataMargins(0, 0, 0.025, 0.025)
self._windowList.reverse()
self.setActivationOrder(qt.QMdiArea.StackingOrder)
self.tileSubWindows()
示例13: __init__
def __init__(self, parent=None):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("Strip and SNIP Configuration Window")
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(0, 0, 0, 0)
self.mainLayout.setSpacing(2)
self.parametersWidget = StripParametersWidget(self)
self.graphWidget = PlotWindow(self, position=False, aspectRatio=False,
colormap=False, yInverted=False,
roi=False, mask=False, fit=False)
toolBar = self.graphWidget.getInteractiveModeToolBar()
toolBar.getZoomModeAction().setVisible(False)
toolBar.getPanModeAction().setVisible(False)
self.mainLayout.addWidget(self.parametersWidget)
self.mainLayout.addWidget(self.graphWidget)
self.getParameters = self.parametersWidget.getParameters
self.setParameters = self.parametersWidget.setParameters
self._x = None
self._y = None
self.parametersWidget.sigStripParametersWidgetSignal.connect( \
self._slot)
示例14: TestRegionOfInterestManager
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]))))
#.........这里部分代码省略.........
示例15: __init__
def __init__(self, parent=None, fit=None, graph=None, actions=True):
qt.QWidget.__init__(self, parent)
self.setWindowTitle("SimpleFitGui")
if fit is None:
self.fitModule = SimpleFitModule.SimpleFit()
self.fitModule.importFunctions(SimpleFitUserEstimatedFunctions)
self.fitModule.loadUserFunctions()
else:
self.fitModule = fit
if graph is None:
self.__useTab = True
self.graph = PlotWindow(self,
aspectRatio=False, colormap=False,
yInverted=False, roi=False, mask=False,
fit=False, control=True, position=True)
self.graph.getInteractiveModeToolBar().setVisible(False)
# No context menu by default, execute zoomBack on right click
plotArea = self.graph.getWidgetHandle()
plotArea.setContextMenuPolicy(qt.Qt.CustomContextMenu)
plotArea.customContextMenuRequested.connect(self._zoomBack)
else:
self.__useTab = False
self.graph = graph
self._configurationDialog = None
self.mainLayout = qt.QVBoxLayout(self)
self.mainLayout.setContentsMargins(2, 2, 2, 2)
self.mainLayout.setSpacing(2)
self.topWidget = TopWidget(self)
config = self.fitModule.getConfiguration()
self.topWidget.setFunctions(config['fit']['functions'])
config = None
if self.__useTab:
self.mainTab = qt.QTabWidget(self)
self.mainLayout.addWidget(self.mainTab)
self.parametersTable = Parameters.Parameters()
self.mainTab.addTab(self.graph, 'GRAPH')
self.mainTab.addTab(self.parametersTable, 'FIT')
else:
self.parametersTable = Parameters.Parameters(self)
self.statusWidget = StatusWidget(self)
self.mainLayout.addWidget(self.topWidget)
if self.__useTab:
self.mainLayout.addWidget(self.mainTab)
else:
self.mainLayout.addWidget(self.parametersTable)
self.mainLayout.addWidget(self.statusWidget)
if actions:
#build the actions widget
self.fitActions = qt.QWidget(self)
self.fitActions.mainLayout = qt.QHBoxLayout(self.fitActions)
self.fitActions.mainLayout.setContentsMargins(2, 2, 2, 2)
self.fitActions.mainLayout.setSpacing(2)
self.fitActions.estimateButton = qt.QPushButton(self.fitActions)
self.fitActions.estimateButton.setText("Estimate")
self.fitActions.startFitButton = qt.QPushButton(self.fitActions)
self.fitActions.startFitButton.setText("Start Fit")
self.fitActions.dismissButton = qt.QPushButton(self.fitActions)
self.fitActions.dismissButton.setText("Dismiss")
self.fitActions.mainLayout.addWidget(self.fitActions.estimateButton)
self.fitActions.mainLayout.addWidget(self.fitActions.startFitButton)
self.fitActions.mainLayout.addWidget(self.fitActions.dismissButton)
self.mainLayout.addWidget(self.fitActions)
#connect top widget
self.topWidget.addFunctionButton.clicked.connect(\
self.importFunctions)
self.topWidget.fitFunctionCombo.currentIndexChanged[int].connect(\
self.fitFunctionComboSlot)
self.topWidget.backgroundCombo.currentIndexChanged[int].connect(\
self.backgroundComboSlot)
self.topWidget.configureButton.clicked.connect(\
self.configureButtonSlot)
if actions:
#connect actions
self.fitActions.estimateButton.clicked.connect(self.estimate)
self.fitActions.startFitButton.clicked.connect(self.startFit)
self.fitActions.dismissButton.clicked.connect(self.dismiss)