示例#1
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()
        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)
示例#2
0
    def __init__(self, filenames=None):
        """
        :param files_: List of HDF5 or Spec files (pathes or
            :class:`silx.io.spech5.SpecH5` or :class:`h5py.File`
            instances)
        """
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Silx HDF5 widget example")

        self.__asyncload = False
        self.__treeview = silx.gui.hdf5.Hdf5TreeView(self)
        """Silx HDF5 TreeView"""
        self.__text = qt.QTextEdit(self)
        """Widget displaying information"""

        self.__dataViewer = DataViewerFrame(self)
        vSpliter = qt.QSplitter(qt.Qt.Vertical)
        vSpliter.addWidget(self.__dataViewer)
        vSpliter.addWidget(self.__text)
        vSpliter.setSizes([10, 0])

        spliter = qt.QSplitter(self)
        spliter.addWidget(self.__treeview)
        spliter.addWidget(vSpliter)
        spliter.setStretchFactor(1, 1)

        main_panel = qt.QWidget(self)
        layout = qt.QVBoxLayout()
        layout.addWidget(spliter)
        layout.addWidget(
            self.createTreeViewConfigurationPanel(self, self.__treeview))
        layout.setStretchFactor(spliter, 1)
        main_panel.setLayout(layout)

        self.setCentralWidget(main_panel)

        # append all files to the tree
        for file_name in filenames:
            self.__treeview.findHdf5TreeModel().appendFile(file_name)

        self.__treeview.activated.connect(self.displayData)
        self.__treeview.activated.connect(
            lambda index: self.displayEvent("activated", index))
        self.__treeview.clicked.connect(
            lambda index: self.displayEvent("clicked", index))
        self.__treeview.doubleClicked.connect(
            lambda index: self.displayEvent("doubleClicked", index))
        self.__treeview.entered.connect(
            lambda index: self.displayEvent("entered", index))
        self.__treeview.pressed.connect(
            lambda index: self.displayEvent("pressed", index))

        self.__treeview.addContextMenuCallback(self.customContextMenu)
        # lambda function will never be called cause we store it as weakref
        self.__treeview.addContextMenuCallback(lambda event: None)
        # you have to store it first
        self.__store_lambda = lambda event: self.closeAndSyncCustomContextMenu(
            event)
        self.__treeview.addContextMenuCallback(self.__store_lambda)
示例#3
0
 def __init__(self, parent=None):
     super(DropExample, self).__init__(parent)
     centralWidget = qt.QWidget(self)
     layout = qt.QVBoxLayout()
     centralWidget.setLayout(layout)
     layout.addWidget(DropPlotWidget(parent=self))
     layout.addWidget(DropLabel(parent=self))
     self.setCentralWidget(centralWidget)
示例#4
0
    def _buildName(self):
        wName = qt.QWidget(self)
        wName.setLayout(qt.QHBoxLayout())

        wName.layout().addWidget(qt.QLabel('name'))
        self._qcbName = qt.QComboBox(wName)
        for val in Colormap.Colormap.getSupportedColormaps():
            self._qcbName.addItem(val)
    def createLegendIconPanel(self, parent):
        panel = qt.QWidget(parent)
        layout = qt.QVBoxLayout(panel)

        # Empty
        legend = LegendIconWidget(panel)
        layout.addWidget(legend)

        # Line
        legend = LegendIconWidget(panel)
        legend.setLineStyle("-")
        legend.setLineColor("blue")
        legend.setLineWidth(2)
        layout.addWidget(legend)

        # Symbol
        legend = LegendIconWidget(panel)
        legend.setSymbol("o")
        legend.setSymbolColor("red")
        layout.addWidget(legend)

        # Line and symbol
        legend = LegendIconWidget(panel)
        legend.setLineStyle(":")
        legend.setLineColor("green")
        legend.setLineWidth(2)
        legend.setSymbol("x")
        legend.setSymbolColor("violet")
        layout.addWidget(legend)

        # Colormap
        legend = LegendIconWidget(panel)
        legend.setColormap("viridis")
        layout.addWidget(legend)

        # Symbol and colormap
        legend = LegendIconWidget(panel)
        legend.setSymbol("o")
        legend.setSymbolColormap("viridis")
        layout.addWidget(legend)

        # Symbol (without surface) and colormap
        legend = LegendIconWidget(panel)
        legend.setSymbol("+")
        legend.setSymbolColormap("plasma")
        layout.addWidget(legend)

        # Colormap + Line + Symbol
        legend = LegendIconWidget(panel)
        legend.setColormap("gray")
        legend.setLineStyle("-")
        legend.setLineColor("white")
        legend.setLineWidth(3)
        legend.setSymbol(".")
        legend.setSymbolColormap("red")
        layout.addWidget(legend)

        return panel
示例#6
0
    def changeWindowFlags(self, node, evt):
        if self.isFloating():
            # The dockWidget will automatically regain it's Qt::widget flag
            # when it becomes docked again
            self.setWindowFlags(qt.Qt.Window | qt.Qt.CustomizeWindowHint
                                | qt.Qt.WindowMaximizeButtonHint)
            # setWindowFlags calls setParent() when changing the flags for a
            # window, causing the widget to be hidden, so:
            self.show()

            # Custom title bar:
            self.titleBar = qt.QWidget()
            self.titleBar.setAutoFillBackground(True)
            self.titleBar.setStyleSheet("QWidget {font: bold; font-size: " +
                                        fontSize + "pt;}")
            pal = self.titleBar.palette()
            pal.setColor(qt.QPalette.Window, qt.QColor("lightgray"))
            self.titleBar.setPalette(pal)
            height = qt.QApplication.style().pixelMetric(
                qt.QStyle.PM_TitleBarHeight)
            self.titleBar.setMaximumHeight(height)
            layout = qt.QHBoxLayout()
            self.titleBar.setLayout(layout)

            buttonSize = qt.QSize(height - 16, height - 16)
            self.titleIcon = qt.QLabel()
            # self.titleIcon.setPixmap(self.parent().runIcon.pixmap(buttonSize))
            self.titleIcon.setPixmap(node.widget.dimIcon.pixmap(buttonSize))
            self.titleIcon.setVisible(True)
            layout.addWidget(self.titleIcon, 0)
            self.title = qt.QLabel(self.windowTitle())
            layout.addWidget(self.title, 0)
            layout.setContentsMargins(4, 4, 4, 4)
            layout.addStretch()

            self.dockButton = qt.QToolButton(self)
            self.dockButton.setIcon(qt.QApplication.style().standardIcon(
                qt.QStyle.SP_ToolBarVerticalExtensionButton))
            self.dockButton.setMaximumSize(buttonSize)
            self.dockButton.setAutoRaise(True)
            self.dockButton.clicked.connect(self.toggleFloating)
            self.dockButton.setToolTip('dock into the main window')
            layout.addWidget(self.dockButton, 0)

            self.maxButton = qt.QToolButton(self)
            self.maxButton.setIcon(qt.QApplication.style().standardIcon(
                qt.QStyle.SP_TitleBarMaxButton))
            self.maxButton.setMaximumSize(buttonSize)
            self.maxButton.setAutoRaise(True)
            self.maxButton.clicked.connect(self.toggleMax)
            layout.addWidget(self.maxButton, 0)

            self.setTitleBarWidget(self.titleBar)

        else:
            self.setTitleBarWidget(None)
            self.parent().setTabIcons()
示例#7
0
    def makeHeaderTab(self):
        self.headerNRB = qt.QRadioButton("has")
        self.headerNEdit = QLineEditSelectRB(rb=self.headerNRB)
        self.headerNEdit.setFixedWidth(28)
        self.headerNEdit.setValidator(
            qt.QIntValidator(0, cco.MAX_HEADER_LINES, self))
        self.headerNLabel2 = qt.QLabel("lines")

        self.headerSRB = qt.QRadioButton("has lines beginning with")
        self.headerSEdit = QLineEditSelectRB(rb=self.headerSRB)
        self.headerSEdit.setFixedWidth(16)

        self.headerERB = qt.QRadioButton("ends with line containing")
        self.headerEEdit = QLineEditSelectRB(rb=self.headerERB)
        self.headerEEdit.setMinimumWidth(30)

        self.headerSRB.setChecked(True)

        headerLayoutN = qt.QHBoxLayout()
        headerLayoutN.addWidget(self.headerNRB)
        headerLayoutN.addWidget(self.headerNEdit)
        headerLayoutN.addWidget(self.headerNLabel2)
        headerLayoutN.addStretch()

        headerLayoutS = qt.QHBoxLayout()
        headerLayoutS.addWidget(self.headerSRB)
        headerLayoutS.addWidget(self.headerSEdit)
        headerLayoutS.addStretch()

        headerLayoutE = qt.QHBoxLayout()
        headerLayoutE.addWidget(self.headerERB)
        headerLayoutE.addWidget(self.headerEEdit, 1)
        headerLayoutE.addStretch()

        headerLayout = qt.QVBoxLayout()
        headerLayout.setContentsMargins(2, 0, 0, 0)
        headerLayout.addLayout(headerLayoutN)
        headerLayout.addLayout(headerLayoutS)
        headerLayout.addLayout(headerLayoutE)
        headerLayout.addStretch()

        tab = qt.QWidget(self)
        tab.setLayout(headerLayout)
        tab.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)

        self.headerKW = 'skiprows', 'comments', 'lastSkipRowContains'
        self.fullHeaderKW = ['dataFormat.' + kw for kw in self.headerKW]
        self.radioButtons = self.headerNRB, self.headerSRB, self.headerERB
        self.edits = self.headerNEdit, self.headerSEdit, self.headerEEdit

        self.registerExclusivePropGroup(
            tab, [self.radioButtons, self.edits], 'header',
            props=self.fullHeaderKW, convertTypes=[int, None, None])

        return tab
示例#8
0
    def getEditor(self, parent, option, index):
        layout = qt.QHBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(qt.QLabel('0'))
        layout.addStretch(1)
        layout.addWidget(qt.QLabel('1'))

        editor = qt.QWidget(parent)
        editor.setLayout(layout)
        return editor
示例#9
0
    def __init__(self, *args, **kwargs):
        qt.QMainWindow.__init__(self, *args, **kwargs)

        widget = qt.QWidget(self)
        self.iconPanel = self.createIconPanel(widget)
        self.sizePanel = self.createSizePanel(widget)

        layout = qt.QVBoxLayout(widget)
        layout.addWidget(self.sizePanel)
        layout.addWidget(self.iconPanel)
        layout.addStretch()
        self.setCentralWidget(widget)
示例#10
0
    def _addStatsWidgetsToLayout(self, qLabel, qLineEdit):
        # create a mother widget to make sure both qLabel & qLineEdit will
        # always be displayed side by side
        widget = qt.QWidget(parent=self)
        widget.setLayout(qt.QHBoxLayout())
        widget.layout().setSpacing(0)
        widget.layout().setContentsMargins(0, 0, 0, 0)

        widget.layout().addWidget(qLabel)
        widget.layout().addWidget(qLineEdit)

        self.layout().addWidget(widget)
    def __init__(self, parent=None):
        qt.QDialog.__init__(self, parent)
        self.setWindowTitle("HDF5 item selection")

        self._tree = Hdf5TreeView(self)
        self._tree.setSelectionMode(qt.QAbstractItemView.SingleSelection)
        self._tree.activated.connect(self._onActivation)
        self._tree.selectionModel().selectionChanged.connect(
            self._onSelectionChange)

        self._model = self._tree.findHdf5TreeModel()

        self._header = self._tree.header()

        self._newItemWidget = qt.QWidget(self)
        newItemLayout = qt.QVBoxLayout(self._newItemWidget)
        self._labelNewItem = qt.QLabel(self._newItemWidget)
        self._labelNewItem.setText(
            "Create new item in selected group (optional):")
        self._lineEditNewItem = qt.QLineEdit(self._newItemWidget)
        self._lineEditNewItem.setToolTip(
            "Specify the name of a new item "
            "to be created in the selected group.")
        self._lineEditNewItem.textChanged.connect(self._onNewItemNameChange)
        newItemLayout.addWidget(self._labelNewItem)
        newItemLayout.addWidget(self._lineEditNewItem)

        _labelSelectionTitle = qt.QLabel(self)
        _labelSelectionTitle.setText("Current selection")
        self._labelSelection = qt.QLabel(self)
        self._labelSelection.setStyleSheet("color: gray")
        self._labelSelection.setWordWrap(True)
        self._labelSelection.setText("Select an item")

        buttonBox = qt.QDialogButtonBox()
        self._okButton = buttonBox.addButton(qt.QDialogButtonBox.Ok)
        self._okButton.setEnabled(False)
        buttonBox.addButton(qt.QDialogButtonBox.Cancel)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)

        vlayout = qt.QVBoxLayout(self)
        vlayout.addWidget(self._tree)
        vlayout.addWidget(self._newItemWidget)
        vlayout.addWidget(_labelSelectionTitle)
        vlayout.addWidget(self._labelSelection)
        vlayout.addWidget(buttonBox)
        self.setLayout(vlayout)

        self.setMinimumWidth(400)

        self._selectedUrl = None
    def __init__(self):
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Plot with synchronized axes")
        widget = qt.QWidget(self)
        self.setCentralWidget(widget)

        layout = qt.QGridLayout()
        widget.setLayout(layout)

        backend = "gl"
        plots = []

        data = numpy.arange(100 * 100)
        data = (data % 100) / 5.0
        data = numpy.sin(data)
        data.shape = 100, 100

        colormaps = ["gray", "red", "green", "blue"]
        for i in range(2 * 2):
            plot = Plot2D(parent=widget, backend=backend)
            plot.setInteractiveMode('pan')
            plot.setDefaultColormap(Colormap(colormaps[i]))
            noisyData = silx.test.utils.add_gaussian_noise(data, mean=i / 10.0)
            plot.addImage(noisyData)
            plots.append(plot)

        xAxis = [p.getXAxis() for p in plots]
        yAxis = [p.getYAxis() for p in plots]

        self.constraint1 = SyncAxes(xAxis,
                                    syncLimits=False,
                                    syncScale=True,
                                    syncDirection=True,
                                    syncCenter=True,
                                    syncZoom=True)
        self.constraint2 = SyncAxes(yAxis,
                                    syncLimits=False,
                                    syncScale=True,
                                    syncDirection=True,
                                    syncCenter=True,
                                    syncZoom=True)

        for i, plot in enumerate(plots):
            if i % 2 == 0:
                plot.setFixedWidth(400)
            else:
                plot.setFixedWidth(500)
            if i // 2 == 0:
                plot.setFixedHeight(400)
            else:
                plot.setFixedHeight(500)
            layout.addWidget(plot, i // 2, i % 2)
示例#13
0
    def setUpClass(cls):
        """Makes sure Qt is inited"""
        global _qapp
        if _qapp is None:
            # Makes sure a QApplication exists and do it once for all
            _qapp = qt.QApplication.instance() or qt.QApplication([])

            # Create/delate a QWidget to make sure init of QDesktopWidget
            _dummyWidget = qt.QWidget()
            _dummyWidget.setAttribute(qt.Qt.WA_DeleteOnClose)
            _dummyWidget.show()
            _dummyWidget.close()
            _qapp.processEvents()
示例#14
0
    def __createCustomNxdataWindow(self, customNxdataWidget):
        toolbar = CustomNxDataToolBar(self)
        toolbar.setCustomNxDataWidget(customNxdataWidget)
        toolbar.setIconSize(qt.QSize(16, 16))
        toolbar.setStyleSheet("QToolBar { border: 0px }")

        widget = qt.QWidget(self)
        layout = qt.QVBoxLayout(widget)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)
        layout.addWidget(toolbar)
        layout.addWidget(customNxdataWidget)
        return widget
示例#15
0
    def __init__(self, parent=None, backend=None):
        qt.QMainWindow.__init__(self, parent=parent, flags=qt.Qt.Dialog)

        self.setWindowTitle('Profile window')
        self._plot1D = None
        self._plot2D = None
        self._backend = backend
        self._data = None

        widget = qt.QWidget()
        self._layout = qt.QStackedLayout(widget)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self.setCentralWidget(widget)
    def __init__(self):
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Plot with synchronized axes")
        widget = qt.QWidget(self)
        self.setCentralWidget(widget)

        layout = qt.QGridLayout()
        widget.setLayout(layout)

        backend = "mpl"

        data = numpy.arange(100 * 100)
        data = (data % 100) / 5.0
        data = numpy.sin(data)
        data = silx.test.utils.add_gaussian_noise(data, mean=0.01)
        data.shape = 100, 100

        data1d = numpy.mean(data, axis=0)

        self.plot2d = plot.Plot2D(parent=widget, backend=backend)
        self.plot2d.setGraphTitle("A pixel can't be too big")
        self.plot2d.setInteractiveMode('pan')
        self.plot2d.addImage(data)
        self.plot2d.getXAxis().setRangeConstraints(minRange=10)
        self.plot2d.getYAxis().setRangeConstraints(minRange=10)

        self.plot2d2 = plot.Plot2D(parent=widget, backend=backend)
        self.plot2d2.setGraphTitle("The image can't be too small")
        self.plot2d2.setInteractiveMode('pan')
        self.plot2d2.addImage(data)
        self.plot2d2.getXAxis().setRangeConstraints(maxRange=200)
        self.plot2d2.getYAxis().setRangeConstraints(maxRange=200)

        self.plot1d = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d.setGraphTitle("The curve is clamped into the view")
        self.plot1d.addCurve(x=numpy.arange(100), y=data1d, legend="mean")
        self.plot1d.getXAxis().setLimitsConstraints(minPos=0, maxPos=100)
        self.plot1d.getYAxis().setLimitsConstraints(minPos=data1d.min(),
                                                    maxPos=data1d.max())

        self.plot1d2 = plot.Plot1D(parent=widget, backend=backend)
        self.plot1d2.setGraphTitle("Only clamp y-axis")
        self.plot1d2.setInteractiveMode('pan')
        self.plot1d2.addCurve(x=numpy.arange(100), y=data1d, legend="mean")
        self.plot1d2.getYAxis().setLimitsConstraints(minPos=data1d.min(),
                                                     maxPos=data1d.max())

        layout.addWidget(self.plot2d, 0, 0)
        layout.addWidget(self.plot1d, 0, 1)
        layout.addWidget(self.plot2d2, 1, 0)
        layout.addWidget(self.plot1d2, 1, 1)
示例#17
0
    def __init__(self, *args, **kwargs):
        qt.QMainWindow.__init__(self, *args, **kwargs)

        widget = qt.QWidget(self)
        self.iconPanel = self.createIconPanel(widget)
        self.sizePanel = self.createSizePanel(widget)

        layout = qt.QVBoxLayout()
        widget.setLayout(layout)
        # layout.setSizeConstraint(qt.QLayout.SetMinAndMaxSize)
        layout.addWidget(self.sizePanel)
        layout.addWidget(self.iconPanel)
        layout.addStretch()
        self.setCentralWidget(widget)
示例#18
0
    def makeDataLocationTab(self):
        if self.node is None:
            return

        self.dataEdits = []
        self.sliceEdits = []
        dataLayout = qt.QVBoxLayout()
        dataLayout.setContentsMargins(2, 0, 0, 0)
        for ia, arrayName in enumerate(self.node.arrays):
            role = self.node.getProp(arrayName, 'role')
            if role.startswith('0'):
                continue
            arrayLayout = qt.QHBoxLayout()
            arrayLayout.setContentsMargins(0, 0, 0, 0)
            lbl = self.node.getProp(arrayName, 'qLabel')
            unit = self.node.getProp(arrayName, 'qUnit')
            if unit:
                lbl += '({0})'.format(unit)
            dataLabel = qt.QLabel(lbl)
            dataEdit = qt.QLineEdit()
            dataEdit.setMinimumWidth(62)
            dataEdit.setSizePolicy(
                qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
            self.dataEdits.append(dataEdit)
            sliceEdit = qt.QLineEdit()
            sliceEdit.setSizePolicy(
                qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)
            self.sliceEdits.append(sliceEdit)
            sliceEdit.textChanged.connect(
                partial(self._resizeToContent, sliceEdit))
            sliceEdit.hide()
            arrayLayout.addWidget(dataLabel)
            arrayLayout.addWidget(dataEdit, 1)
            arrayLayout.addWidget(sliceEdit, 0)
            dataLayout.addLayout(arrayLayout)
            self.registerPropWidget(
                (dataLabel, dataEdit), dataLabel.text(),
                # ('dataFormat.dataSource', ia), convertType=int)
                'dataFormat.dataSource.int({0})'.format(ia), convertType=int)
            self.registerPropWidget(
                sliceEdit, 'slice', 'dataFormat.slices.int({0})'.format(ia),
                hideEmpty=True)

        tab = qt.QWidget(self)
        tab.setLayout(dataLayout)
        tab.setSizePolicy(qt.QSizePolicy.Expanding, qt.QSizePolicy.Fixed)

        self.registerPropGroup(tab, self.dataEdits, 'data location')

        return tab
示例#19
0
        def __init__(self):
            AbstractMaskImageWidget.__init__(self)

            self.__maskWidget = PyMcaMaskImageWidget.MaskImageWidget()

            widget = qt.QWidget()
            layout = qt.QVBoxLayout()
            layout.setContentsMargins(0, 0, 0, 0)
            layout.addWidget(self.__maskWidget)
            layout.setStretch(0, 1)
            layout.addWidget(self._saveAndClose)
            widget.setLayout(layout)

            self.setCentralWidget(widget)
示例#20
0
    def __init__(self, parent=None):
        super(ColormapDialogExample, self).__init__(parent)
        self.setWindowTitle("Colormap dialog example")

        self.colormap1 = Colormap("viridis")
        self.colormap2 = Colormap("gray")

        self.colorBar = ColorBarWidget(self)

        self.colorDialogs = []

        options = qt.QWidget(self)
        options.setLayout(qt.QVBoxLayout())
        self.createOptions(options.layout())

        mainWidget = qt.QWidget(self)
        mainWidget.setLayout(qt.QHBoxLayout())
        mainWidget.layout().addWidget(options)
        mainWidget.layout().addWidget(self.colorBar)
        self.mainWidget = mainWidget

        self.setCentralWidget(mainWidget)
        self.createColorDialog()
    def _buildToolbar(self):
        toolBar = qt.QWidget(self)
        # a layout for the toolbar
        toolsLayout = qt.QHBoxLayout(toolBar)
        toolsLayout.setContentsMargins(0, 0, 0, 0)
        toolsLayout.setSpacing(0)

        hideBut = qt.QPushButton("Hide", toolBar)
        hideBut.setToolTip("Hide print preview dialog")
        hideBut.clicked.connect(self.hide)

        cancelBut = qt.QPushButton("Clear All", toolBar)
        cancelBut.setToolTip("Remove all items")
        cancelBut.clicked.connect(self._clearAll)

        removeBut = qt.QPushButton("Remove",
                                   toolBar)
        removeBut.setToolTip("Remove selected item (use left click to select)")
        removeBut.clicked.connect(self._remove)

        setupBut = qt.QPushButton("Setup", toolBar)
        setupBut.setToolTip("Select and configure a printer")
        setupBut.clicked.connect(self.setup)

        printBut = qt.QPushButton("Print", toolBar)
        printBut.setToolTip("Print page and close print preview")
        printBut.clicked.connect(self._print)

        zoomPlusBut = qt.QPushButton("Zoom +", toolBar)
        zoomPlusBut.clicked.connect(self._zoomPlus)

        zoomMinusBut = qt.QPushButton("Zoom -", toolBar)
        zoomMinusBut.clicked.connect(self._zoomMinus)

        toolsLayout.addWidget(hideBut)
        toolsLayout.addWidget(printBut)
        toolsLayout.addWidget(cancelBut)
        toolsLayout.addWidget(removeBut)
        toolsLayout.addWidget(setupBut)
        # toolsLayout.addStretch()
        # toolsLayout.addWidget(marginLabel)
        # toolsLayout.addWidget(self.marginSpin)
        toolsLayout.addStretch()
        # toolsLayout.addWidget(scaleLabel)
        # toolsLayout.addWidget(self.scaleCombo)
        toolsLayout.addWidget(zoomPlusBut)
        toolsLayout.addWidget(zoomMinusBut)
        # toolsLayout.addStretch()
        self.toolBar = toolBar
        self.mainLayout.addWidget(self.toolBar)
示例#22
0
 def makeTransformWidget(self, parent):
     tr = self.node.transformIn
     tr.sendSignals = csi.mainWindow is not None
     hasWidgetClass = tr is not None
     if hasWidgetClass:
         hasWidgetClass = tr.widgetClass is not None
     if hasWidgetClass:
         self.transformWidget = tr.widgetClass(parent=parent,
                                               node=self.node,
                                               transform=tr)
     else:
         self.transformWidget = qt.QWidget(parent)
     if tr is not None:
         tr.widget = self.transformWidget
示例#23
0
    def __init__(self):
        """
        :param files_: List of HDF5 or Spec files (pathes or
            :class:`silx.io.spech5.SpecH5` or :class:`h5py.File`
            instances)
        """
        # Import it here to be sure to use the right logging level
        import silx.gui.hdf5
        from silx.gui.data.DataViewerFrame import DataViewerFrame

        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Silx viewer")

        self.__asyncload = False
        self.__dialogState = None
        self.__treeview = silx.gui.hdf5.Hdf5TreeView(self)
        """Silx HDF5 TreeView"""

        self.__dataViewer = DataViewerFrame(self)
        vSpliter = qt.QSplitter(qt.Qt.Vertical)
        vSpliter.addWidget(self.__dataViewer)
        vSpliter.setSizes([10, 0])

        spliter = qt.QSplitter(self)
        spliter.addWidget(self.__treeview)
        spliter.addWidget(vSpliter)
        spliter.setStretchFactor(1, 1)

        main_panel = qt.QWidget(self)
        layout = qt.QVBoxLayout()
        layout.addWidget(spliter)
        layout.setStretchFactor(spliter, 1)
        main_panel.setLayout(layout)

        self.setCentralWidget(main_panel)

        model = self.__treeview.selectionModel()
        model.selectionChanged.connect(self.displayData)
        self.__treeview.addContextMenuCallback(
            self.closeAndSyncCustomContextMenu)

        treeModel = self.__treeview.findHdf5TreeModel()
        columns = list(treeModel.COLUMN_IDS)
        columns.remove(treeModel.DESCRIPTION_COLUMN)
        columns.remove(treeModel.NODE_COLUMN)
        self.__treeview.header().setSections(columns)

        self.createActions()
        self.createMenus()
示例#24
0
    def createWidget(self, parent):
        """Inherit the method to create a new editor"""
        widget = qt.QWidget(parent)
        layout = qt.QHBoxLayout(widget)
        if isinstance(parent, qt.QMenu):
            margins = layout.contentsMargins()
            layout.setContentsMargins(margins.left(), 0, margins.right(), 0)
        else:
            layout.setContentsMargins(0, 0, 0, 0)

        editorClass = self.getEditorClass(self.__roi)
        editor = editorClass(parent)
        editor.setEditorData(self.__roi)
        self.__setEditor(widget, editor)
        return widget
示例#25
0
    def __init__(self, parent=None, urls=()):
        super(DragAndDropExample, self).__init__(parent)
        centralWidget = qt.QWidget(self)
        layout = qt.QVBoxLayout()
        centralWidget.setLayout(layout)
        layout.addWidget(
            qt.QLabel(
                "Drag and drop one of the following URLs on the plot or on the URL information zone:",
                self))
        for url in urls:
            layout.addWidget(DragLabel(parent=self, url=url))

        layout.addWidget(DropPlotWidget(parent=self))
        layout.addWidget(DropLabel(parent=self))

        self.setCentralWidget(centralWidget)
示例#26
0
    def createSizePanel(self, parent):
        group = qt.QButtonGroup()
        group.setExclusive(True)
        panel = qt.QWidget(parent)
        panel.setLayout(qt.QHBoxLayout())

        for size in [16, 24, 32]:
            button = qt.QPushButton("%spx" % size, panel)
            button.clicked.connect(functools.partial(self.setIconSize, size))
            button.setCheckable(True)
            panel.layout().addWidget(button)
            group.addButton(button)

        self.__sizeGroup = group
        button.setChecked(True)
        return panel
示例#27
0
    def __init__(self):
        """Constructor"""
        qt.QMainWindow.__init__(self)
        self.setWindowTitle("Silx simple widget example")

        main_panel = qt.QWidget(self)
        main_panel.setLayout(qt.QVBoxLayout())

        main_panel.layout().addWidget(qt.QLabel("WaitingPushButton"))
        main_panel.layout().addWidget(self.createWaitingPushButton())
        main_panel.layout().addWidget(self.createWaitingPushButton2())

        main_panel.layout().addWidget(qt.QLabel("ThreadPoolPushButton"))
        main_panel.layout().addWidget(self.createThreadPoolPushButton())

        self.setCentralWidget(main_panel)
示例#28
0
 def _initTransparencyWidget(self):
     """ Init the mask transparency widget """
     transparencyWidget = qt.QWidget(parent=self)
     grid = qt.QGridLayout()
     grid.setContentsMargins(0, 0, 0, 0)
     self.transparencySlider = qt.QSlider(qt.Qt.Horizontal, parent=transparencyWidget)
     self.transparencySlider.setRange(3, 10)
     self.transparencySlider.setValue(8)
     self.transparencySlider.setToolTip(
             'Set the transparency of the mask display')
     self.transparencySlider.valueChanged.connect(self._updateColors)
     grid.addWidget(qt.QLabel('Display:', parent=transparencyWidget), 0, 0)
     grid.addWidget(self.transparencySlider, 0, 1, 1, 3)
     grid.addWidget(qt.QLabel('<small><b>Transparent</b></small>', parent=transparencyWidget), 1, 1)
     grid.addWidget(qt.QLabel('<small><b>Opaque</b></small>', parent=transparencyWidget), 1, 3)
     transparencyWidget.setLayout(grid)
     return transparencyWidget
示例#29
0
    def __init__(self):
        AbstractMaskImageWidget.__init__(self)

        self.__plot2D = silx.gui.plot.Plot2D()
        self.__plot2D.setKeepDataAspectRatio(True)
        if hasattr(self.__plot2D, "getMaskAction"):
            # silx 0.5 and later
            maskAction = self.__plot2D.getMaskAction()
        else:
            # silx 0.4 and previous
            maskAction = self.__plot2D.maskAction
        maskAction.setVisible(False)
        self.__maskPanel = silx.gui.plot.MaskToolsWidget.MaskToolsWidget(
            plot=self.__plot2D)
        try:
            colormap = {
                'name': "inferno",
                'normalization': 'log',
                'autoscale': True,
                'vmax': None,
                'vmin': None,
            }
            self.__plot2D.setDefaultColormap(colormap)
        except Exception:
            _logger.error(
                "Impossible to change the default colormap. Source code not compatible.",
                exc_info=True)
        self.__maskPanel.setDirection(qt.QBoxLayout.TopToBottom)
        self.__maskPanel.setMultipleMasks("single")

        panelLayout = qt.QVBoxLayout()
        panelLayout.addWidget(self.__maskPanel)
        panelLayout.setStretch(0, 1)
        panelLayout.addWidget(self._saveAndClose)

        widget = qt.QWidget()
        layout = qt.QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)

        layout = qt.QHBoxLayout()
        layout.addWidget(self.__plot2D)
        layout.setStretch(0, 1)
        layout.addLayout(panelLayout)
        widget.setLayout(layout)

        self.setCentralWidget(widget)
示例#30
0
    def __init__(self, parent=None):
        super(DialogExample, self).__init__(parent)

        self.__state = {}

        centralWidget = qt.QWidget(self)
        layout = qt.QHBoxLayout()
        centralWidget.setLayout(layout)

        options = self.createOptions()
        layout.addWidget(options)

        buttonGroup = qt.QGroupBox()
        buttonGroup.setTitle("Create dialog")
        layout.addWidget(buttonGroup)
        buttonLayout = qt.QVBoxLayout()
        buttonGroup.setLayout(buttonLayout)

        # ImageFileDialog

        b1 = qt.QPushButton(self)
        b1.setMinimumHeight(50)
        b1.setText("Open a dialog")
        b1.clicked.connect(self.openDialog)
        buttonLayout.addWidget(b1)

        b2 = qt.QPushButton(self)
        b2.setMinimumHeight(50)
        b2.setText("Open a dialog with state stored")
        b2.clicked.connect(self.openDialogStoredState)
        buttonLayout.addWidget(b2)

        b3 = qt.QPushButton(self)
        b3.setMinimumHeight(50)
        b3.setText("Open a dialog at home")
        b3.clicked.connect(self.openDialogAtHome)
        buttonLayout.addWidget(b3)

        b4 = qt.QPushButton(self)
        b4.setMinimumHeight(50)
        b4.setText("Open a dialog at computer root")
        b4.clicked.connect(self.openDialogAtComputer)
        buttonLayout.addWidget(b4)

        self.setCentralWidget(centralWidget)