Esempio n. 1
0
    def _initColorBar(self):
        """Create the ColorBarWidget and add it to the PlotWidget"""

        # Add a colorbar on the right side
        colorBar = ColorBarWidget(parent=self, plot=self)

        # Make ColorBarWidget background white by changing its palette
        colorBar.setAutoFillBackground(True)
        palette = colorBar.palette()
        palette.setColor(qt.QPalette.Background, qt.Qt.white)
        palette.setColor(qt.QPalette.Window, qt.Qt.white)
        colorBar.setPalette(palette)

        # Add the ColorBarWidget by changing PlotWidget's central widget
        gridLayout = qt.QGridLayout()
        gridLayout.setSpacing(0)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        plot = self.getWidgetHandle()  # Get the widget rendering the plot
        gridLayout.addWidget(plot, 0, 0)
        gridLayout.addWidget(colorBar, 0, 1)
        gridLayout.setRowStretch(0, 1)
        gridLayout.setColumnStretch(0, 1)
        centralWidget = qt.QWidget()
        centralWidget.setLayout(gridLayout)
        self.setCentralWidget(centralWidget)
Esempio n. 2
0
    def __init__(self, parent=None):
        super(MyPlotWindow, self).__init__(parent)

        # Create a PlotWidget
        self._plot = PlotWidget(parent=self)

        # Create a colorbar linked with the PlotWidget
        colorBar = ColorBarWidget(parent=self, plot=self._plot)

        # Make ColorBarWidget background white by changing its palette
        colorBar.setAutoFillBackground(True)
        palette = colorBar.palette()
        palette.setColor(qt.QPalette.Background, qt.Qt.white)
        palette.setColor(qt.QPalette.Window, qt.Qt.white)
        colorBar.setPalette(palette)

        # Combine the ColorBarWidget and the PlotWidget as
        # this QMainWindow's central widget
        gridLayout = qt.QGridLayout()
        gridLayout.setSpacing(0)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        gridLayout.addWidget(self._plot, 0, 0)
        gridLayout.addWidget(colorBar, 0, 1)
        gridLayout.setRowStretch(0, 1)
        gridLayout.setColumnStretch(0, 1)
        centralWidget = qt.QWidget(self)
        centralWidget.setLayout(gridLayout)
        self.setCentralWidget(centralWidget)

        # Add ready to use toolbar with zoom and pan interaction mode buttons
        interactionToolBar = tools.InteractiveModeToolBar(parent=self,
                                                          plot=self._plot)
        self.addToolBar(interactionToolBar)
        # Add toolbar actions to activate keyboard shortcuts
        self.addActions(interactionToolBar.actions())

        # Add a new toolbar
        toolBar = qt.QToolBar("Plot Tools", self)
        self.addToolBar(toolBar)

        # Add actions from silx.gui.plot.action to the toolbar
        resetZoomAction = actions.control.ResetZoomAction(parent=self,
                                                          plot=self._plot)
        toolBar.addAction(resetZoomAction)

        # Add tool buttons from silx.gui.plot.PlotToolButtons
        aspectRatioButton = PlotToolButtons.AspectToolButton(parent=self,
                                                             plot=self._plot)
        toolBar.addWidget(aspectRatioButton)

        # Add ready to use toolbar with copy, save and print buttons
        outputToolBar = tools.OutputToolBar(parent=self, plot=self._plot)
        self.addToolBar(outputToolBar)
        # Add toolbar actions to activate keyboard shortcuts
        self.addActions(outputToolBar.actions())

        # Add limits tool bar from silx.gui.plot.PlotTools
        limitsToolBar = tools.LimitsToolBar(parent=self, plot=self._plot)
        self.addToolBar(qt.Qt.BottomToolBarArea, limitsToolBar)
Esempio n. 3
0
    def __init__(self, parent=None):
        super(MyPlotWindow, self).__init__(parent)

        # Create a PlotWidget
        self._plot = PlotWidget(parent=self)

        # Create a colorbar linked with the PlotWidget
        colorBar = ColorBarWidget(parent=self, plot=self._plot)

        # Make ColorBarWidget background white by changing its palette
        colorBar.setAutoFillBackground(True)
        palette = colorBar.palette()
        palette.setColor(qt.QPalette.Background, qt.Qt.white)
        palette.setColor(qt.QPalette.Window, qt.Qt.white)
        colorBar.setPalette(palette)

        # Combine the ColorBarWidget and the PlotWidget as
        # this QMainWindow's central widget
        gridLayout = qt.QGridLayout()
        gridLayout.setSpacing(0)
        gridLayout.setContentsMargins(0, 0, 0, 0)
        gridLayout.addWidget(self._plot, 0, 0)
        gridLayout.addWidget(colorBar, 0, 1)
        gridLayout.setRowStretch(0, 1)
        gridLayout.setColumnStretch(0, 1)
        centralWidget = qt.QWidget(self)
        centralWidget.setLayout(gridLayout)
        self.setCentralWidget(centralWidget)

        # Add ready to use toolbar with zoom and pan interaction mode buttons
        interactionToolBar = tools.InteractiveModeToolBar(
            parent=self, plot=self._plot)
        self.addToolBar(interactionToolBar)
        # Add toolbar actions to activate keyboard shortcuts
        self.addActions(interactionToolBar.actions())

        # Add a new toolbar
        toolBar = qt.QToolBar("Plot Tools", self)
        self.addToolBar(toolBar)

        # Add actions from silx.gui.plot.action to the toolbar
        resetZoomAction = actions.control.ResetZoomAction(
            parent=self, plot=self._plot)
        toolBar.addAction(resetZoomAction)

        # Add tool buttons from silx.gui.plot.PlotToolButtons
        aspectRatioButton = PlotToolButtons.AspectToolButton(
            parent=self, plot=self._plot)
        toolBar.addWidget(aspectRatioButton)

        # Add ready to use toolbar with copy, save and print buttons
        outputToolBar = tools.OutputToolBar(parent=self, plot=self._plot)
        self.addToolBar(outputToolBar)
        # Add toolbar actions to activate keyboard shortcuts
        self.addActions(outputToolBar.actions())

        # Add limits tool bar from silx.gui.plot.PlotTools
        limitsToolBar = tools.LimitsToolBar(parent=self, plot=self._plot)
        self.addToolBar(qt.Qt.BottomToolBarArea, limitsToolBar)