Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def createActions(self):
action = qt.QAction("E&xit", self)
action.setShortcuts(qt.QKeySequence.Quit)
action.setStatusTip("Exit the application")
action.triggered.connect(self.close)
self._exitAction = action
action = qt.QAction("&Open", self)
action.setStatusTip("Open a file")
action.triggered.connect(self.open)
self._openAction = action
action = qt.QAction("&About", self)
action.setStatusTip("Show the application's About box")
action.triggered.connect(self.about)
self._aboutAction = action
def __init__(self, parent=None, plot=None):
super(PrintPreviewToolButton, self).__init__(parent)
if not isinstance(plot, PlotWidget):
raise TypeError("plot parameter must be a PlotWidget")
self.plot = plot
self.setIcon(icons.getQIcon('document-print'))
printGeomAction = qt.QAction("Print geometry", self)
printGeomAction.setToolTip("Define a print geometry prior to sending "
"the plot to the print preview dialog")
printGeomAction.setIcon(icons.getQIcon('shape-rectangle')) # fixme: icon not displayed in menu
printGeomAction.triggered.connect(self._setPrintConfiguration)
printPreviewAction = qt.QAction("Print preview", self)
printPreviewAction.setToolTip("Send plot to the print preview dialog")
printPreviewAction.setIcon(icons.getQIcon('document-print')) # fixme: icon not displayed
printPreviewAction.triggered.connect(self._plotToPrintPreview)
menu = qt.QMenu(self)
menu.addAction(printGeomAction)
menu.addAction(printPreviewAction)
self.setMenu(menu)
self.setPopupMode(qt.QToolButton.InstantPopup)
self._printPreviewDialog = None
self._printConfigurationDialog = None
self._printGeometry = {"xOffset": 0.1,
"yOffset": 0.1,
"width": 0.9,
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)
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 _initThresholdGroupBox(self):
"""Init thresholding widgets"""
self.belowThresholdAction = qt.QAction(icons.getQIcon('plot-roi-below'),
'Mask below threshold',
self)
self.belowThresholdAction.setToolTip(
'Mask image where values are below given threshold')
self.belowThresholdAction.setCheckable(True)
self.belowThresholdAction.setChecked(True)
self.betweenThresholdAction = qt.QAction(icons.getQIcon('plot-roi-between'),
'Mask within range',
self)
self.betweenThresholdAction.setToolTip(
'Mask image where values are within given range')
self.betweenThresholdAction.setCheckable(True)
self.aboveThresholdAction = qt.QAction(icons.getQIcon('plot-roi-above'),
'Mask above threshold',
action.setCheckable(True)
action.setToolTip("Extract contiguous peaks")
toolBar.addAction(action)
self.__peakSelectionMode = action
toolBar.addSeparator()
action = qt.QAction(self)
action.setIcon(icons.getQIcon("silx:gui/icons/draw-brush"))
action.setText("Brush")
action.setCheckable(True)
action.setToolTip("Change the ring number to a set of already identified peaks")
toolBar.addAction(action)
self.__brushMode = action
action = qt.QAction(self)
action.setIcon(icons.getQIcon("silx:gui/icons/draw-rubber"))
action.setText("Rubber")
action.setCheckable(True)
action.setToolTip("Remove a set of already identified peaks")
toolBar.addAction(action)
self.__erasorMode = action
toolBar.addSeparator()
action = qt.QAction(self)
action.setIcon(icons.getQIcon("pyfai:gui/icons/new-ring"))
action.setText("+")
action.setCheckable(True)
action.setChecked(True)
action.setToolTip("Create always a new ring when a peak is picked")
toolBar.addAction(action)
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)
action.setStatusTip("Show the Silx library's documentation")
action.triggered.connect(self.showDocumentation)
self._documentationAction = action
# Plot backend
action = qt.QAction("Plot rendering backend", self)
action.setStatusTip("Select plot rendering backend")
self._plotBackendSelection = action
menu = qt.QMenu()
action.setMenu(menu)
group = qt.QActionGroup(self)
group.setExclusive(True)
action = qt.QAction("matplotlib", self)
action.setStatusTip("Plot will be rendered using matplotlib")
action.setCheckable(True)
action.triggered.connect(self.__forceMatplotlibBackend)
group.addAction(action)
menu.addAction(action)
self._usePlotWithMatplotlib = action
action = qt.QAction("OpenGL", self)
action.setStatusTip("Plot will be rendered using OpenGL")
action.setCheckable(True)
action.triggered.connect(self.__forceOpenglBackend)
group.addAction(action)
menu.addAction(action)
self._usePlotWithOpengl = action
# Plot image orientation
def __popupUnitSelection(self, pos):
"""Display a popup list to allow to select a new unit"""
if self.__unit is None:
return
unitList = units.Unit.get_units(self.__unit.dimensionality)
if len(unitList) <= 1:
return
menu = qt.QMenu(self)
menu.addSection("Unit for %s" % self.__unit.dimensionality.fullname.lower())
for unit in unitList:
action = qt.QAction(menu)
text = u"%s: %s" % (unit.fullname, unit.symbol)
if unit is self.__unit:
text += " (current)"
action.setText(text)
action.triggered.connect(functools.partial(self.__unitSelected, unit))
menu.addAction(action)
menu.popup(pos)
action.setShortcuts(qt.QKeySequence.Quit)
action.setStatusTip("Exit the application")
action.triggered.connect(self.close)
self._exitAction = action
action = qt.QAction("&Open...", self)
action.setStatusTip("Open a file")
action.triggered.connect(self.open)
self._openAction = action
action = qt.QAction("Open Recent", self)
action.setStatusTip("Open a recently openned file")
action.triggered.connect(self.open)
self._openRecentAction = action
action = qt.QAction("Close All", self)
action.setStatusTip("Close all opened files")
action.triggered.connect(self.closeAll)
self._closeAllAction = action
action = qt.QAction("&About", self)
action.setStatusTip("Show the application's About box")
action.triggered.connect(self.about)
self._aboutAction = action
action = qt.QAction("&Documentation", self)
action.setStatusTip("Show the Silx library's documentation")
action.triggered.connect(self.showDocumentation)
self._documentationAction = action
# Plot backend