def __initContent(self): """Create all expected actions and set the content of this toolbar.""" action = qt.QAction("Create a new custom NXdata", self) action.setIcon(icons.getQIcon("nxdata-create")) action.triggered.connect(self.__createNewNxdata) self.addAction(action) self.__addNxDataAction = action action = qt.QAction("Remove the selected NXdata", self) action.setIcon(icons.getQIcon("nxdata-remove")) action.triggered.connect(self.__removeSelectedNxdata) self.addAction(action) self.__removeNxDataAction = action self.addSeparator() action = qt.QAction("Create a new axis to the selected NXdata", self) action.setIcon(icons.getQIcon("nxdata-axis-add")) action.triggered.connect(self.__appendNewAxisToSelectedNxdata) self.addAction(action) self.__addNxDataAxisAction = action action = qt.QAction("Remove the selected NXdata axis", self) action.setIcon(icons.getQIcon("nxdata-axis-remove")) action.triggered.connect(self.__removeSelectedAxis) self.addAction(action) self.__removeNxDataAxisAction = action
def __init__(self, parent=None): self.__pixmap = None self.__positionCount = None self.__firstValue = 0. self.__secondValue = 1. self.__minValue = 0. self.__maxValue = 1. self.__hoverRect = qt.QRect() self.__hoverControl = None self.__focus = None self.__moving = None self.__icons = { 'first': icons.getQIcon('previous'), 'second': icons.getQIcon('next') } # call the super constructor AFTER defining all members that # are used in the "paint" method super(RangeSlider, self).__init__(parent) self.setFocusPolicy(qt.Qt.ClickFocus) self.setAttribute(qt.Qt.WA_Hover) self.setMinimumSize(qt.QSize(50, 20)) self.setMaximumHeight(20) # Broadcast value changed signal self.sigValueChanged.connect(self.__emitPositionChanged)
def __createOptionsWidget(self): menu = qt.QMenu(self) # Load peak selection as file loadPeaksFromFile = qt.QAction(self) icon = icons.getQIcon('document-open') loadPeaksFromFile.setIcon(icon) loadPeaksFromFile.setText("Load peak selection from file") loadPeaksFromFile.triggered.connect(self.__loadPeaksFromFile) loadPeaksFromFile.setIconVisibleInMenu(True) menu.addAction(loadPeaksFromFile) # Save peak selection as file savePeaksAsFile = qt.QAction(self) icon = icons.getQIcon('document-save') savePeaksAsFile.setIcon(icon) savePeaksAsFile.setText("Save peak selection as file") savePeaksAsFile.triggered.connect(self.__savePeaksAsFile) savePeaksAsFile.setIconVisibleInMenu(True) menu.addAction(savePeaksAsFile) options = qt.QToolButton(self) icon = icons.getQIcon('pyfai:gui/icons/options') options.setIcon(icon) options.setPopupMode(qt.QToolButton.InstantPopup) options.setMenu(menu) return options
def __init__(self, parent, label, unit): qt.QObject.__init__(self, parent=parent) validator = validators.DoubleValidator(self) self.__label = qt.QLabel(parent) self.__label.setText(label) self.__lineEdit = qt.QLineEdit(parent) self.__lineEdit.setValidator(validator) self.__lineEdit.setAlignment(qt.Qt.AlignRight) self.__lineEdit.editingFinished.connect(self.__lineEditChanged) self.__unit = qt.QLabel(parent) self.__unit.setText(unit) self.__constraints = qt.QToolButton(parent) self.__constraints.setAutoRaise(True) self.__constraints.clicked.connect(self.__constraintsClicked) self.__model = None self.__wavelengthInvalidated = False self.__constraintsModel = None global _iconVariableFixed, _iconVariableConstrained, _iconVariableConstrainedOut if _iconVariableFixed is None: _iconVariableFixed = icons.getQIcon("pyfai:gui/icons/variable-fixed") if _iconVariableConstrained is None: _iconVariableConstrained = icons.getQIcon("pyfai:gui/icons/variable-constrained") if _iconVariableConstrainedOut is None: _iconVariableConstrainedOut = icons.getQIcon("pyfai:gui/icons/variable-constrained-out")
def __init__(self): super(PeakPickingTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self) self.initNextStep() self.__dialogState = None layout = qt.QVBoxLayout(self._imageHolder) self.__plot = _PeakPickingPlot(parent=self._imageHolder) toolBar = self.__createPlotToolBar(self.__plot) self.__plot.addToolBar(toolBar) statusBar = self.__createPlotStatusBar(self.__plot) self.__plot.setStatusBar(statusBar) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._ringSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-ring")) self._peakSelectionMode.setIcon(icons.getQIcon("pyfai:gui/icons/search-peak")) self.__peakSelectionView = None self.__plot.sigPlotSignal.connect(self.__onPlotEvent) self.__undoStack = qt.QUndoStack(self) self._undoButton.setDefaultAction(self.__undoStack.createUndoAction(self, "Undo")) self._redoButton.setDefaultAction(self.__undoStack.createRedoAction(self, "Redo")) self.__mode = qt.QButtonGroup() self.__mode.setExclusive(True) self.__mode.addButton(self._peakSelectionMode) self.__mode.addButton(self._ringSelectionMode) self._ringSelectionMode.setChecked(True) self._extract.clicked.connect(self.__autoExtractRings)
def __createTreeWindow(self, treeView): toolbar = qt.QToolBar(self) toolbar.setIconSize(qt.QSize(16, 16)) toolbar.setStyleSheet("QToolBar { border: 0px }") action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-expand-all")) action.setText("Expand all") action.setToolTip("Expand all selected items") action.triggered.connect(self.__expandAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Plus)) toolbar.addAction(action) treeView.addAction(action) self.__expandAllAction = action action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-collapse-all")) action.setText("Collapse all") action.setToolTip("Collapse all selected items") action.triggered.connect(self.__collapseAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Minus)) toolbar.addAction(action) treeView.addAction(action) self.__collapseAllAction = action widget = qt.QWidget(self) layout = qt.QVBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(toolbar) layout.addWidget(treeView) return widget
def __init__(self, parent=None, plot=None, stats=None, rois=None): qt.QMainWindow.__init__(self, parent) toolbar = qt.QToolBar(self) icon = icons.getQIcon('add') self._rois = list(rois) if rois is not None else [] self._addAction = qt.QAction(icon, 'add item/roi', toolbar) self._addAction.triggered.connect(self._addRoiStatsItem) icon = icons.getQIcon('rm') self._removeAction = qt.QAction(icon, 'remove item/roi', toolbar) self._removeAction.triggered.connect(self._removeCurrentRow) toolbar.addAction(self._addAction) toolbar.addAction(self._removeAction) self.addToolBar(toolbar) self._plot = plot self._statsROITable = _StatsROITable(parent=self, plot=self._plot) self.setStats(stats=stats) self.setCentralWidget(self._statsROITable) self.setWindowFlags(qt.Qt.Widget) # expose API self._setUpdateMode = self._statsROITable.setUpdateMode self._updateAllStats = self._statsROITable._updateAllStats # setup self._statsROITable.setSelectionBehavior(qt.QTableWidget.SelectRows)
def __createTreeWindow(self, treeView): toolbar = qt.QToolBar(self) toolbar.setIconSize(qt.QSize(16, 16)) toolbar.setStyleSheet("QToolBar { border: 0px }") action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("view-refresh")) action.setText("Refresh") action.setToolTip("Refresh all selected items") action.triggered.connect(self.__refreshSelected) action.setShortcut(qt.QKeySequence(qt.Qt.Key_F5)) toolbar.addAction(action) treeView.addAction(action) self.__refreshAction = action # Another shortcut for refresh action = qt.QAction(toolbar) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_R)) treeView.addAction(action) action.triggered.connect(self.__refreshSelected) action = qt.QAction(toolbar) # action.setIcon(icons.getQIcon("view-refresh")) action.setText("Close") action.setToolTip("Close selected item") action.triggered.connect(self.__removeSelected) action.setShortcut(qt.QKeySequence(qt.Qt.Key_Delete)) treeView.addAction(action) self.__closeAction = action toolbar.addSeparator() action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-expand-all")) action.setText("Expand all") action.setToolTip("Expand all selected items") action.triggered.connect(self.__expandAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Plus)) toolbar.addAction(action) treeView.addAction(action) self.__expandAllAction = action action = qt.QAction(toolbar) action.setIcon(icons.getQIcon("tree-collapse-all")) action.setText("Collapse all") action.setToolTip("Collapse all selected items") action.triggered.connect(self.__collapseAllSelected) action.setShortcut(qt.QKeySequence(qt.Qt.ControlModifier + qt.Qt.Key_Minus)) toolbar.addAction(action) treeView.addAction(action) self.__collapseAllAction = action widget = qt.QWidget(self) layout = qt.QVBoxLayout(widget) layout.setContentsMargins(0, 0, 0, 0) layout.setSpacing(0) layout.addWidget(toolbar) layout.addWidget(treeView) return widget
def testCacheReleased(self): icon1 = icons.getQIcon("crop") icon1_id = str(icon1.__repr__()) icon1 = None # alloc another thing in case the old icon1 object is reused _icon3 = icons.getQIcon("colormap") icon2 = icons.getQIcon("crop") icon2_id = str(icon2.__repr__()) self.assertNotEquals(icon1_id, icon2_id)
def __init__(self, parent=None, plot=None, title=''): super(_BaseProfileToolBar, self).__init__(title, parent) self.__profile = None self.__profileTitle = '' assert isinstance(plot, PlotWidget) self._plotRef = weakref.ref( plot, WeakMethodProxy(self.__plotDestroyed)) self._profileWindow = None # Set-up interaction manager roiManager = RegionOfInterestManager(plot) self._roiManagerRef = weakref.ref(roiManager) roiManager.sigInteractiveModeFinished.connect( self.__interactionFinished) roiManager.sigRegionOfInterestChanged.connect(self.updateProfile) roiManager.sigRegionOfInterestAdded.connect(self.__roiAdded) # Add interactive mode actions for kind, icon, tooltip in ( ('hline', 'shape-horizontal', 'Enables horizontal line profile selection mode'), ('vline', 'shape-vertical', 'Enables vertical line profile selection mode'), ('line', 'shape-diagonal', 'Enables line profile selection mode')): action = roiManager.getInteractionModeAction(kind) action.setIcon(icons.getQIcon(icon)) action.setToolTip(tooltip) self.addAction(action) # Add clear action action = qt.QAction(icons.getQIcon('profile-clear'), 'Clear Profile', self) action.setToolTip('Clear the profile') action.setCheckable(False) action.triggered.connect(self.clearProfile) self.addAction(action) # Initialize color self._color = None self.setColor('red') # Listen to plot limits changed plot.getXAxis().sigLimitsChanged.connect(self.updateProfile) plot.getYAxis().sigLimitsChanged.connect(self.updateProfile) # Listen to plot scale plot.getXAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged) plot.getYAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged) self.setDefaultProfileWindowEnabled(True)
def __init__(self, parent=None, plot=None, title=''): super(_BaseProfileToolBar, self).__init__(title, parent) self.__profile = None self.__profileTitle = '' assert isinstance(plot, PlotWidget) self._plotRef = weakref.ref(plot, WeakMethodProxy(self.__plotDestroyed)) self._profileWindow = None # Set-up interaction manager roiManager = RegionOfInterestManager(plot) self._roiManagerRef = weakref.ref(roiManager) roiManager.sigInteractiveModeFinished.connect( self.__interactionFinished) roiManager.sigRoiChanged.connect(self.updateProfile) roiManager.sigRoiAdded.connect(self.__roiAdded) # Add interactive mode actions for kind, icon, tooltip in ( (roi_items.HorizontalLineROI, 'shape-horizontal', 'Enables horizontal line profile selection mode'), (roi_items.VerticalLineROI, 'shape-vertical', 'Enables vertical line profile selection mode'), (roi_items.LineROI, 'shape-diagonal', 'Enables line profile selection mode')): action = roiManager.getInteractionModeAction(kind) action.setIcon(icons.getQIcon(icon)) action.setToolTip(tooltip) self.addAction(action) # Add clear action action = qt.QAction(icons.getQIcon('profile-clear'), 'Clear Profile', self) action.setToolTip('Clear the profile') action.setCheckable(False) action.triggered.connect(self.clearProfile) self.addAction(action) # Initialize color self._color = None self.setColor('red') # Listen to plot limits changed plot.getXAxis().sigLimitsChanged.connect(self.updateProfile) plot.getYAxis().sigLimitsChanged.connect(self.updateProfile) # Listen to plot scale plot.getXAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged) plot.getYAxis().sigScaleChanged.connect(self.__plotAxisScaleChanged) self.setDefaultProfileWindowEnabled(True)
def __init__(self, parent=None): qt.QToolBar.__init__(self, parent) self.setIconSize(qt.QSize(16, 16)) action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-active-items")) action.setText("Active items only") action.setToolTip("Display stats for active items only.") action.setCheckable(True) action.setChecked(True) self.__displayActiveItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-items")) action.setText("All items") action.setToolTip("Display stats for all available items.") action.setCheckable(True) self.__displayWholeItems = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-visible-data")) action.setText("Use the visible data range") action.setToolTip("Use the visible data range.<br/>" "If activated the data is filtered to only use" "visible data of the plot." "The filtering is a data sub-sampling." "No interpolation is made to fit data to" "boundaries.") action.setCheckable(True) self.__useVisibleData = action action = qt.QAction(self) action.setIcon(icons.getQIcon("stats-whole-data")) action.setText("Use the full data range") action.setToolTip("Use the full data range.") action.setCheckable(True) action.setChecked(True) self.__useWholeData = action self.addAction(self.__displayWholeItems) self.addAction(self.__displayActiveItems) self.addSeparator() self.addAction(self.__useVisibleData) self.addAction(self.__useWholeData) self.itemSelection = qt.QActionGroup(self) self.itemSelection.setExclusive(True) self.itemSelection.addAction(self.__displayActiveItems) self.itemSelection.addAction(self.__displayWholeItems) self.dataRangeSelection = qt.QActionGroup(self) self.dataRangeSelection.setExclusive(True) self.dataRangeSelection.addAction(self.__useWholeData) self.dataRangeSelection.addAction(self.__useVisibleData)
def __init__(self, parent=None, n=None): qt.QWidget.__init__(self, parent) # Use the font size as the icon size to avoid to create bigger buttons fontMetric = self.fontMetrics() iconSize = qt.QSize(fontMetric.height(), fontMetric.height()) self.mainLayout = qt.QHBoxLayout(self) self.mainLayout.setContentsMargins(0, 0, 0, 0) self.mainLayout.setSpacing(0) self.firstButton = qt.QPushButton(self) self.firstButton.setIcon(icons.getQIcon("first")) self.firstButton.setIconSize(iconSize) self.previousButton = qt.QPushButton(self) self.previousButton.setIcon(icons.getQIcon("previous")) self.previousButton.setIconSize(iconSize) self._lineEdit = qt.QLineEdit(self) self._label = qt.QLabel(self) self.nextButton = qt.QPushButton(self) self.nextButton.setIcon(icons.getQIcon("next")) self.nextButton.setIconSize(iconSize) self.lastButton = qt.QPushButton(self) self.lastButton.setIcon(icons.getQIcon("last")) self.lastButton.setIconSize(iconSize) self.mainLayout.addWidget(self.firstButton) self.mainLayout.addWidget(self.previousButton) self.mainLayout.addWidget(self._lineEdit) self.mainLayout.addWidget(self._label) self.mainLayout.addWidget(self.nextButton) self.mainLayout.addWidget(self.lastButton) if n is None: first = qt.QSlider().minimum() last = qt.QSlider().maximum() else: first, last = 0, n self._lineEdit.setFixedWidth(self._lineEdit.fontMetrics().width( '%05d' % last)) validator = qt.QIntValidator(first, last, self._lineEdit) self._lineEdit.setValidator(validator) self._lineEdit.setText("%d" % first) self._label.setText("of %d" % last) self._index = first """0-based index""" self.firstButton.clicked.connect(self._firstClicked) self.previousButton.clicked.connect(self._previousClicked) self.nextButton.clicked.connect(self._nextClicked) self.lastButton.clicked.connect(self._lastClicked) self._lineEdit.editingFinished.connect(self._textChangedSlot)
def __init__(self): super(PeakPickingTask, self).__init__() qt.loadUi(pyFAI.utils.get_ui_file("calibration-peakpicking.ui"), self) self.initNextStep() # Insert the plot on the layout holder = self._plotHolder self.__plot = _PeakPickingPlot(parent=holder) holderLayout = qt.QVBoxLayout(holder) holderLayout.setContentsMargins(1, 1, 1, 1) holderLayout.addWidget(self.__plot) # Insert the peak view on the layout holder = self._peakSelectionDummy.parent() self.__peakSelectionView = _PeakSelectionTableView(holder) holderLayout = holder.layout() holderLayout.replaceWidget(self._peakSelectionDummy, self.__peakSelectionView) self.__createPlotToolBar(self.__plot) statusBar = self.__createPlotStatusBar(self.__plot) self.__plot.setStatusBar(statusBar) self._ringSelectionMode.setIcon( icons.getQIcon("pyfai:gui/icons/search-ring")) self._peakSelectionMode.setIcon( icons.getQIcon("pyfai:gui/icons/search-peak")) self.__plot.sigPlotSignal.connect(self.__onPlotEvent) self.__undoStack = qt.QUndoStack(self) undoAction = CustomProxyAction( self, self.__undoStack.createUndoAction(self, "Undo")) undoAction.forceText("Undo") undoAction.forceIconText("Undo") redoAction = CustomProxyAction( self, self.__undoStack.createRedoAction(self, "Redo")) redoAction.forceText("Redo") redoAction.forceIconText("Redo") self._undoButton.setDefaultAction(undoAction) self._redoButton.setDefaultAction(redoAction) self.__mode = qt.QButtonGroup() self.__mode.setExclusive(True) self.__mode.addButton(self._peakSelectionMode) self.__mode.addButton(self._ringSelectionMode) self._ringSelectionMode.setChecked(True) self._extract.clicked.connect(self.__autoExtractRingsLater) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self, *args, **kwargs): super(SampleTable, self).__init__(*args, **kwargs) self.mainLayout = qt.QVBoxLayout(self) self.setLayout(self.mainLayout) self.lbl = np.array([]) self.data = np.array([]) self.df = None self.column_labels = None self.filename = None self.addBtn = qt.QPushButton(self) self.addBtn.setFixedWidth(30) self.addBtn.setFixedHeight(30) self.addBtn.setIcon(getQIcon('shape-cross')) self.addBtn.setToolTip("Add sample below") self.addBtn.clicked.connect(self.addRecord) self.minusBtn = qt.QPushButton(self) self.minusBtn.setFixedWidth(30) self.minusBtn.setFixedHeight(30) self.minusBtn.setIcon(getQIcon('close')) self.minusBtn.setToolTip("Remove current row") self.minusBtn.clicked.connect(self.removeRecord) self.loadBtn = qt.QPushButton(self) self.loadBtn.setFixedWidth(30) self.loadBtn.setFixedHeight(30) self.loadBtn.setIcon(getQIcon('document-open')) self.loadBtn.clicked.connect(self.load) self.loadBtn.setToolTip("Load from the excel file") self.saveBtn = qt.QPushButton(self) self.saveBtn.setFixedWidth(30) self.saveBtn.setFixedHeight(30) self.saveBtn.setIcon(getQIcon('document-save')) self.saveBtn.clicked.connect(self.save) self.saveBtn.setToolTip("Save to the excel file") buttons = addWidgets( [self.addBtn, self.minusBtn, self.loadBtn, self.saveBtn], align='right') self.table = TableWidget(self) self.table.setAlternatingRowColors(True) # self.table.horizontalHeader().setSectionResizeMode(qt.QHeaderView.Stretch) self.mainLayout.addWidget(buttons) self.mainLayout.addWidget(self.table)
def __init__(self, input_data=None, output_path=None, json_file=".azimint.json", context=None): qt.QWidget.__init__(self) filename = get_ui_file("integration-dialog.ui") qt.loadUi(filename, self) pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.__context = context if context is not None: context.restoreWindowLocationSettings("main-window", self) self.__workerConfigurator = WorkerConfigurator(self._holder) self.__content = qt.QWidget(self) layout = qt.QVBoxLayout(self.__content) layout.addWidget(self.__workerConfigurator) self._holder.setWidget(self.__content) self._holder.minimumSizeHint = self.__minimumScrollbarSizeHint size = self.__content.minimumSizeHint() self._holder.setMaximumHeight(size.height() + 2) size = self.minimumSizeHint() - self._holder.minimumSizeHint() + size self.setMaximumHeight(size.height() + 2) self.input_data = input_data self.output_path = output_path self.json_file = json_file self.batch_processing.clicked.connect(self.__fireBatchProcess) self.save_json_button.clicked.connect(self.save_config) self.quit_button.clicked.connect(self.die) if self.json_file is not None: self.restore(self.json_file)
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-settings") self.setWindowIcon(icon) self.initNextStep() self._imageLoader.clicked.connect(self.loadImage) self._maskLoader.clicked.connect(self.loadMask) self._darkLoader.clicked.connect(self.loadDark) self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) self.__plot.setObjectName("plot-experiment") self.__plotBackground = SynchronizePlotBackground(self.__plot) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self, parent=None): super(ImageWidget, self).__init__(parent=parent, backend=None, resetzoom=True, autoScale=False, logScale=False, grid=False, curveStyle=False, colormap=True, aspectRatio=True, yInverted=True, copy=True, save=True, print_=False, control=False, roi=False, mask=True) if parent is None: self.setWindowTitle('comImageWidget') self.setKeepDataAspectRatio(True) self.setYAxisInverted(True) self.getMaskToolsDockWidget().setWindowTitle('diffraction ROI') self.getMaskAction().setToolTip( 'Select a diffraction region of interest') self.getMaskAction().setIcon(getQIcon('image-select-box')) # set default colormap self.setDefaultColormap({ 'name': 'temperature', 'autoscale': True, 'normalization': 'log' })
def __createPlot(self, parent): plot = silx.gui.plot.PlotWidget(parent=parent) plot.setKeepDataAspectRatio(True) plot.setDataMargins(0.1, 0.1, 0.1, 0.1) plot.setGraphXLabel("X") plot.setGraphYLabel("Y") colormap = CalibrationContext.instance().getRawColormap() plot.setDefaultColormap(colormap) from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar) toolBar = qt.QToolBar(self) plot3dAction = qt.QAction(self) plot3dAction.setIcon(icons.getQIcon("pyfai:gui/icons/3d")) plot3dAction.setText("3D visualization") plot3dAction.setToolTip("Display a 3D visualization of the detector") plot3dAction.triggered.connect(self.__display3dDialog) toolBar.addAction(plot3dAction) plot.addToolBar(toolBar) return plot
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-experiment.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-settings") self.setWindowIcon(icon) self.initNextStep() self._detectorLabel.setAcceptDrops(True) self._image.setAcceptDrops(True) self._mask.setAcceptDrops(True) self._imageLoader.setDialogTitle("Load calibration image") self._maskLoader.setDialogTitle("Load mask image") self._darkLoader.setDialogTitle("Load dark image") self._customDetector.clicked.connect(self.__customDetector) self.__plot = self.__createPlot(parent=self._imageHolder) self.__plot.setObjectName("plot-experiment") self.__plotBackground = SynchronizePlotBackground(self.__plot) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) self._detectorFileDescription.setElideMode(qt.Qt.ElideMiddle) self._calibrant.setFileLoadable(True) self._calibrant.sigLoadFileRequested.connect(self.loadCalibrant) self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __init__(self, parent=None, maskImageWidget=None): """ :param maskImageWidget: Parent SilxMaskImageWidget """ qt.QToolButton.__init__(self, parent) self.maskImageWidget = maskImageWidget self.setIcon(icons.getQIcon("document-save")) self.clicked.connect(self._saveToolButtonSignal) self.setToolTip('Save Graph') self._saveMenu = qt.QMenu() self._saveMenu.addAction( SaveImageListAction("Image Data", self.maskImageWidget)) self._saveMenu.addAction( SaveImageListAction("Colormap Clipped Seen Image Data", self.maskImageWidget, clipped=True)) self._saveMenu.addAction( SaveImageListAction("Clipped and Subtracted Seen Image Data", self.maskImageWidget, clipped=True, subtract=True)) # standard silx save action self._saveMenu.addAction(PlotActions.SaveAction( plot=self.maskImageWidget.plot, parent=self)) if QPyMcaMatplotlibSave is not None: self._saveMenu.addAction(SaveMatplotlib("Matplotlib", self.maskImageWidget))
def __init__(self, parent): super(_StackView, self).__init__( parent=parent, modeId=STACK_MODE, label="Image stack", icon=icons.getQIcon("view-2d-stack")) self.__resetZoomNextTime = True
def __init__(self, parent=None, maskImageWidget=None): """ :param maskImageWidget: Parent SilxMaskImageWidget """ qt.QToolButton.__init__(self, parent) self.maskImageWidget = maskImageWidget self.setIcon(icons.getQIcon("document-save")) self.clicked.connect(self._saveToolButtonSignal) self.setToolTip('Save Graph') self._saveMenu = qt.QMenu() self._saveMenu.addAction( SaveImageListAction("Image Data", self.maskImageWidget)) self._saveMenu.addAction( SaveImageListAction("Colormap Clipped Seen Image Data", self.maskImageWidget, clipped=True)) self._saveMenu.addAction( SaveImageListAction("Clipped and Subtracted Seen Image Data", self.maskImageWidget, clipped=True, subtract=True)) # standard silx save action self._saveMenu.addAction( PlotActions.SaveAction(plot=self.maskImageWidget.plot, parent=self)) if QPyMcaMatplotlibSave is not None: self._saveMenu.addAction( SaveMatplotlib("Matplotlib", self.maskImageWidget))
def createProfileAction(self, profileRoiClass, parent=None): """Create an action from a class of ProfileRoi :param core.ProfileRoiMixIn profileRoiClass: A class of a profile ROI :param qt.QObject parent: The parent of the created action. :rtype: qt.QAction """ if not issubclass(profileRoiClass, core.ProfileRoiMixIn): raise TypeError("Type %s not expected" % type(profileRoiClass)) roiManager = self.getRoiManager() action = CreateRoiModeAction(parent, roiManager, profileRoiClass) if hasattr(profileRoiClass, "ICON"): action.setIcon(icons.getQIcon(profileRoiClass.ICON)) if hasattr(profileRoiClass, "NAME"): def articulify(word): """Add an an/a article in the front of the word""" first = word[1] if word[0] == 'h' else word[0] if first in "aeiou": return "an " + word return "a " + word action.setText('Define %s' % articulify(profileRoiClass.NAME)) action.setToolTip('Enables %s selection mode' % profileRoiClass.NAME) action.setSingleShot(True) return action
def __init__(self, input_data=None, output_path=None, json_file=".azimint.json", context=None): qt.QWidget.__init__(self) filename = get_ui_file("integration-dialog.ui") qt.loadUi(filename, self) pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.__context = context if context is not None: context.restoreWindowLocationSettings("main-window", self) self.__workerConfigurator = WorkerConfigurator(self._holder) layout = qt.QVBoxLayout(self._holder) layout.addWidget(self.__workerConfigurator) layout.setContentsMargins(0, 0, 0, 0) self._holder.setLayout(layout) self.input_data = input_data self.output_path = output_path self.json_file = json_file self.batch_processing.clicked.connect(self.__fireBatchProcess) self.save_json_button.clicked.connect(self.save_config) self.quit_button.clicked.connect(self.die) self.progressBar.setVisible(False) self.progressBar.setValue(0) if self.json_file is not None: self.restore(self.json_file)
def __init__(self, parent): super(_Plot2dView, self).__init__( parent=parent, modeId=PLOT2D_MODE, label="Image", icon=icons.getQIcon("view-2d")) self.__resetZoomNextTime = True
def __init__(self, parent): super(_ImageView, self).__init__(parent=parent, modeId=IMAGE_MODE, label="Image", icon=icons.getQIcon("view-2d")) self.addView(_ComplexImageView(parent)) self.addView(_Plot2dView(parent))
def _initGui(self): qt.loadUi(pyFAI.utils.get_ui_file("calibration-geometry.ui"), self) icon = icons.getQIcon("pyfai:gui/icons/task-fit-geometry") self.setWindowIcon(icon) self.initNextStep() self.widgetShow.connect(self.__widgetShow) self.__plot = self.__createPlot() self.__plot.sigMouseMove.connect(self.__mouseMoved) self.__plot.sigMouseLeave.connect(self.__mouseLeft) layout = qt.QVBoxLayout(self._imageHolder) layout.addWidget(self.__plot) layout.setContentsMargins(1, 1, 1, 1) self._imageHolder.setLayout(layout) userAngleUnit = CalibrationContext.instance().getAngleUnit() userLengthUnit = CalibrationContext.instance().getLengthUnit() userWavelengthUnit = CalibrationContext.instance().getWavelengthUnit() layout = qt.QGridLayout(self._settings) self.__wavelength = FitParamView(self, "Wavelength:", units.Unit.METER_WL, userWavelengthUnit) self.addParameterToLayout(layout, self.__wavelength) layout = qt.QGridLayout(self._geometry) self.__distance = FitParamView(self, "Distance:", units.Unit.METER, userLengthUnit) self.__poni1 = FitParamView(self, "PONI1:", units.Unit.METER, userLengthUnit) self.__poni2 = FitParamView(self, "PONI2:", units.Unit.METER, userLengthUnit) self.__rotation1 = FitParamView(self, "Rotation 1:", units.Unit.RADIAN, userAngleUnit) self.__rotation2 = FitParamView(self, "Rotation 2:", units.Unit.RADIAN, userAngleUnit) self.__rotation3 = FitParamView(self, "Rotation 3:", units.Unit.RADIAN, userAngleUnit) self.addParameterToLayout(layout, self.__distance) self.addParameterToLayout(layout, self.__poni1) self.addParameterToLayout(layout, self.__poni2) self.addParameterToLayout(layout, self.__rotation1) self.addParameterToLayout(layout, self.__rotation2) self.addParameterToLayout(layout, self.__rotation3) self._fitButton.clicked.connect(self.__fitGeometryLater) self._fitButton.setDisabledWhenWaiting(True) self._resetButton.clicked.connect(self.__resetGeometryLater) self.__calibration = None self.__peaksInvalidated = False self.__fitting = False self.__wavelengthInvalidated = False self.__synchronizeRawView = SynchronizeRawView() self.__synchronizeRawView.registerTask(self) self.__synchronizeRawView.registerPlot(self.__plot)
def __getNxIcon(self, baseIcon): iconHash = baseIcon.cacheKey() icon = self.__iconCache.get(iconHash, None) if icon is None: nxIcon = icons.getQIcon("layer-nx") icon = self.__createCompoundIcon(baseIcon, nxIcon) self.__iconCache[iconHash] = icon return icon
def __init__(self, parent, plot3d=None): super(VideoAction, self).__init__(parent, plot3d) self.setText('Record video..') self.setIcon(getQIcon('camera')) self.setToolTip( 'Record a video of a 360 degrees rotation of the 3D scene.') self.setCheckable(False) self.triggered[bool].connect(self._triggered)
def __init__(self, parent): super(_RawView, self).__init__(parent=parent, modeId=DataViewer.RAW_MODE, label="Raw", icon=icons.getQIcon("view-raw")) self.addView(_ScalarView(parent)) self.addView(_ArrayView(parent)) self.addView(_RecordView(parent))
def __init__(self, parent): super(_ImageView, self).__init__( parent=parent, modeId=IMAGE_MODE, label="Image", icon=icons.getQIcon("view-2d")) self.addView(_ComplexImageView(parent)) self.addView(_Plot2dView(parent))
def __init__(self, plot, parent=None): # Uses two images for checked/unchecked states self._states = { False: (icons.getQIcon('plot-ydown'), "Orient Y axis downward"), True: (icons.getQIcon('plot-yup'), "Orient Y axis upward"), } icon, tooltip = self._states[plot.getYAxis().isInverted()] super(YAxisInvertedAction, self).__init__(plot, icon=icon, text='Invert Y Axis', tooltip=tooltip, triggered=self._actionTriggered, checkable=False, parent=parent) plot.getYAxis().sigInvertedChanged.connect(self._yAxisInvertedChanged)
def toggleViewAction(self): """Returns a checkable action that shows or closes this widget. See :class:`QMainWindow`. """ action = super(BaseMaskToolsDockWidget, self).toggleViewAction() action.setIcon(icons.getQIcon('image-mask')) action.setToolTip("Display/hide mask tools") return action
def _warningIcon(self): if self._cacheWarningIcon is None: icon = icons.getQIcon("pyfai:gui/icons/warning") pixmap = icon.pixmap(64) coloredIcon = qt.QIcon() coloredIcon.addPixmap(pixmap, qt.QIcon.Normal) coloredIcon.addPixmap(pixmap, qt.QIcon.Disabled) self._cacheWarningIcon = coloredIcon return self._cacheWarningIcon
def __init__(self, parent): super(_RawView, self).__init__( parent=parent, modeId=RAW_MODE, label="Raw", icon=icons.getQIcon("view-raw")) self.addView(_HexaView(parent)) self.addView(_ScalarView(parent)) self.addView(_ArrayView(parent)) self.addView(_RecordView(parent))
def __init__(self, plot, parent=None): # Uses two images for checked/unchecked states self._states = { False: (icons.getQIcon('plot-ydown'), "Orient Y axis downward"), True: (icons.getQIcon('plot-yup'), "Orient Y axis upward"), } icon, tooltip = self._states[plot.getYAxis().isInverted()] super(YAxisInvertedAction, self).__init__( plot, icon=icon, text='Invert Y Axis', tooltip=tooltip, triggered=self._actionTriggered, checkable=False, parent=parent) plot.getYAxis().sigInvertedChanged.connect(self._yAxisInvertedChanged)
def __init__(self, parent, plot3d=None): super(CopyAction, self).__init__(parent, plot3d) self.setIcon(getQIcon('edit-copy')) self.setText('Copy') self.setToolTip('Copy a snapshot of the 3D scene to the clipboard') self.setCheckable(False) self.setShortcut(qt.QKeySequence.Copy) self.setShortcutContext(qt.Qt.WidgetShortcut) self.triggered[bool].connect(self._triggered)
def __init__(self, parent, plot3d=None): super(SaveAction, self).__init__(parent, plot3d) self.setIcon(getQIcon('document-save')) self.setText('Save...') self.setToolTip('Save a snapshot of the 3D scene') self.setCheckable(False) self.setShortcut(qt.QKeySequence.Save) self.setShortcutContext(qt.Qt.WidgetShortcut) self.triggered[bool].connect(self._triggered)
def __init__(self, plot, parent=None): # Uses two images for checked/unchecked states self._states = { False: (icons.getQIcon('shape-circle-solid'), "Keep data aspect ratio"), True: (icons.getQIcon('shape-ellipse-solid'), "Do no keep data aspect ratio") } icon, tooltip = self._states[plot.isKeepDataAspectRatio()] super(KeepAspectRatioAction, self).__init__( plot, icon=icon, text='Toggle keep aspect ratio', tooltip=tooltip, triggered=self._actionTriggered, checkable=False, parent=parent) plot.sigSetKeepDataAspectRatio.connect( self._keepDataAspectRatioChanged)
def createDefaultContextMenu(self, index): """Create a default context menu at this position. :param qt.QModelIndex index: Index of the item """ index = self.__model.index(index.row(), 0, parent=index.parent()) item = self.__model.itemFromIndex(index) menu = qt.QMenu() weakself = weakref.proxy(self) if isinstance(item, _NxDataItem): action = qt.QAction("Add a new axis", menu) action.triggered.connect(lambda: weakself.model().appendAxisToNxdataItem(item)) action.setIcon(icons.getQIcon("nxdata-axis-add")) action.setIconVisibleInMenu(True) menu.addAction(action) menu.addSeparator() action = qt.QAction("Remove this NXdata", menu) action.triggered.connect(lambda: weakself.model().removeNxdataItem(item)) action.setIcon(icons.getQIcon("remove")) action.setIconVisibleInMenu(True) menu.addAction(action) else: if isinstance(item, _DatasetItemRow): if item.getDataset() is not None: action = qt.QAction("Remove this dataset", menu) action.triggered.connect(lambda: item.setDataset(None)) menu.addAction(action) if isinstance(item, _DatasetAxisItemRow): menu.addSeparator() action = qt.QAction("Remove this axis", menu) action.triggered.connect(lambda: weakself.model().removeAxisItem(item)) action.setIcon(icons.getQIcon("remove")) action.setIconVisibleInMenu(True) menu.addAction(action) return menu
def __init__(self, parent): super(_Plot3dView, self).__init__( parent=parent, modeId=PLOT3D_MODE, label="Cube", icon=icons.getQIcon("view-3d")) try: import silx.gui.plot3d #noqa except ImportError: _logger.warning("Plot3dView is not available") _logger.debug("Backtrace", exc_info=True) raise self.__resetZoomNextTime = True
def __init__(self, parent): super(_NXdataView, self).__init__( parent=parent, label="NXdata", modeId=NXDATA_MODE, icon=icons.getQIcon("view-nexus")) self.addView(_InvalidNXdataView(parent)) self.addView(_NXdataScalarView(parent)) self.addView(_NXdataCurveView(parent)) self.addView(_NXdataXYVScatterView(parent)) self.addView(_NXdataImageView(parent)) self.addView(_NXdataStackView(parent))
def __init__(self, parent=None, sceneGlWindow=None): """ :param QWidget parent: Parent widget :param SceneGLWindow sceneGlWindow: :class:`SceneGlWindow` displaying the data. """ super(OpenAction, self).__init__(parent) self._sceneGlWindow = sceneGlWindow self.setIcon(icons.getQIcon("document-open")) self.setText("Load data from a file") self.setCheckable(False) self.triggered[bool].connect(self._openMenu)
def __createPlotToolBar(self, plot): from silx.gui.plot import tools toolBar = tools.InteractiveModeToolBar(parent=self, plot=plot) plot.addToolBar(toolBar) toolBar = tools.ImageToolBar(parent=self, plot=plot) colormapDialog = CalibrationContext.instance().getColormapDialog() toolBar.getColormapAction().setColorDialog(colormapDialog) plot.addToolBar(toolBar) toolBar = qt.QToolBar(self) plot3dAction = qt.QAction(self) plot3dAction.setIcon(icons.getQIcon("pyfai:gui/icons/3d")) plot3dAction.setText("3D visualization") plot3dAction.setToolTip("Display a 3D visualization of the sample stage") plot3dAction.triggered.connect(self.__display3dDialog) toolBar.addAction(plot3dAction) plot.addToolBar(toolBar)
def __init__(self): qt.QWidget.__init__(self) self.integration_config = {} self.list_dataset = ListDataSet() # Contains all datasets to be treated. try: qt.loadUi(get_ui_file(self.uif), self) except AttributeError as _error: logger.error("I looks like your installation suffers from this bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=697348") raise RuntimeError("Please upgrade your installation of PyQt (or apply the patch)") pyfaiIcon = icons.getQIcon("pyfai:gui/images/icon") self.setWindowIcon(pyfaiIcon) self.aborted = False self.progressBar.setValue(0) self.list_model = TreeModel(self, self.list_dataset.as_tree()) self.listFiles.setModel(self.list_model) self.listFiles.setSelectionBehavior(qt.QAbstractItemView.SelectRows) self.listFiles.setSelectionMode(qt.QAbstractItemView.ExtendedSelection) self.create_connections() self.set_validator() self.update_number_of_frames() self.update_number_of_points() self.processing_thread = None self.processing_sem = threading.Semaphore() self.update_sem = threading.Semaphore() # disable some widgets: self.multiframe.setVisible(False) self.label_10.setVisible(False) self.frameShape.setVisible(False) # Online visualization self.fig = None self.axplt = None self.aximg = None self.img = None self.plot = None self.radial_data = None self.data_h5 = None # one in hdf5 dataset while processing. self.data_np = None # The numpy one is used only at the end. self.last_idx = -1 self.slice = slice(0, -1, 1) # Default slicing self._menu_file()
def __init__(self, plot, icon, text, tooltip=None, triggered=None, checkable=False, parent=None): assert plot is not None self._plotRef = weakref.ref(plot) if not isinstance(icon, qt.QIcon): # Try with icon as a string and load corresponding icon icon = icons.getQIcon(icon) super(PlotAction, self).__init__(icon, text, parent) if tooltip is not None: self.setToolTip(tooltip) self.setCheckable(checkable) if triggered is not None: self.triggered[bool].connect(triggered)
def createEditor(self, parent, option, index): if not index.isValid(): return super(_PeakToolItemDelegate, self).createEditor(parent, option, index) editor = qt.QToolBar(parent=parent) editor.setIconSize(qt.QSize(32, 32)) editor.setStyleSheet("QToolBar { border: 0px }") editor.setMinimumSize(32, 32) editor.setMaximumSize(32, 32) editor.setSizePolicy(qt.QSizePolicy.Fixed, qt.QSizePolicy.Fixed) remove = qt.QAction(editor) remove.setIcon(icons.getQIcon("pyfai:gui/icons/remove-peak")) remove._customSignal = None persistantIndex = qt.QPersistentModelIndex(index) remove.triggered.connect(functools.partial(self.__removePeak, persistantIndex)) editor.addAction(remove) return editor
def __init__(self, parent=None): super(ViewpointToolButton, self).__init__(parent) self._plot3DRef = None menu = qt.QMenu(self) menu.addAction(actions.viewpoint.FrontViewpointAction(parent=self)) menu.addAction(actions.viewpoint.BackViewpointAction(parent=self)) menu.addAction(actions.viewpoint.TopViewpointAction(parent=self)) menu.addAction(actions.viewpoint.BottomViewpointAction(parent=self)) menu.addAction(actions.viewpoint.RightViewpointAction(parent=self)) menu.addAction(actions.viewpoint.LeftViewpointAction(parent=self)) menu.addAction(actions.viewpoint.SideViewpointAction(parent=self)) self.setMenu(menu) self.setPopupMode(qt.QToolButton.InstantPopup) self.setIcon(getQIcon('cube')) self.setToolTip('Reset the viewpoint to a defined position')