Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, perspective, view=None, parent=None, designMode=False):
BaseToolBar.__init__(self, name="Taurus refresh toolbar", view=view,
parent=parent, designMode=designMode)
self._perspective = perspective
view = self.viewWidget()
b = self._perspective_button = Qt.QToolButton(self)
b.setToolTip("Perspective selection")
b.setPopupMode(Qt.QToolButton.InstantPopup)
b.setToolButtonStyle(Qt.Qt.ToolButtonTextBesideIcon)
menu = Qt.QMenu("Perspective", b)
b.setMenu(menu)
af = ActionFactory()
for persp, persp_data in view.KnownPerspectives.items():
label = persp_data["label"]
icon = getIcon(persp_data["icon"])
tip = persp_data["tooltip"]
action = af.createAction(self, label, icon=icon, tip=tip,
triggered=self.onSwitchPerspective)
action.perspective = persp
menu.addAction(action)
if persp == perspective:
b.setDefaultAction(action)
from taurus.qt.qtgui.container import TaurusMainWindow, TaurusWidget
from taurus.qt.qtcore.configuration import BaseConfigurableClass
from taurus.qt.qtgui.display import TaurusLed
from taurus.qt.qtgui.dialog import TaurusMessageBox
from taurus.qt.qtgui.extra_macroexecutor.macroparameterseditor import ParamEditorManager, StandardMacroParametersEditor
from taurus.qt.qtgui.extra_macroexecutor.macroparameterseditor.delegate import ParamEditorDelegate
from taurus.core.tango.sardana.macro import MacroRunException, MacroNode
from model import MacroSequenceTreeModel, MacroSequenceProxyModel, MacroParametersProxyModel
from delegate import SequenceEditorDelegate
from taurus.qt.qtgui.extra_macroexecutor import globals
from taurus.qt.qtgui.resource import getIcon, getThemeIcon
class HookAction(Qt.QAction):
def __init__(self, text, parent, macroNode):
Qt.QAction.__init__(self, text, parent)
self.setCheckable(True)
self.setMacroNode(macroNode)
if text in self.macroNode().hookPlaces():
self.setChecked(True)
self.setToolTip("This macro will be executed as a %s" % text)
self.connect(self, Qt.SIGNAL('toggled(bool)'), self.onToggle)
def macroNode(self):
return self._macroNode
def setMacroNode(self, macroNode):
self._macroNode = macroNode
def setStatusLabelPalette(self, label):
"""
Set the label look as as status label
"""
label.setAutoFillBackground(True)
palette = label.palette()
gradient = Qt.QLinearGradient(0, 0, 0, 15)
gradient.setColorAt(0.0, Qt.QColor.fromRgb( 60, 150, 255))
gradient.setColorAt(0.5, Qt.QColor.fromRgb( 0, 85, 227))
gradient.setColorAt(1.0, Qt.QColor.fromRgb( 60, 150, 255))
gradient.setSpread(Qt.QGradient.RepeatSpread)
palette.setBrush(Qt.QPalette.Window, Qt.QBrush(gradient))
palette.setBrush(Qt.QPalette.WindowText, Qt.Qt.white)
def loadFile(self, iniFileName=None):
if iniFileName is None:
if self.currentFile is None: path = Qt.QDir.homePath()
else: path = self.currentFile
iniFileName = Qt.QFileDialog.getOpenFileName ( self, 'Select a settings file', path, 'Ini Files (*.ini)')
self.currentFile = unicode(iniFileName)
self.settings = Qt.QSettings(iniFileName, Qt.QSettings.IniFormat)
self.fillTopLevel()
self.setWindowTitle('TaurusConfigBrowser - %s'%os.path.basename(self.currentFile))
def initComponents(self):
self.setLayout(Qt.QFormLayout())
self.layout().addRow(Qt.QLabel("Setting environment variable:", self))
self.nameComboBox = ComboBoxParam(self)
self.nameComboBox.addItems(["ActiveMntGrp", "ExtraColumns", "JsonRecorder", "ScanFile", "ScanDir"])
self.nameComboBox.setEditable(True)
self.connect(self.nameComboBox, Qt.SIGNAL("currentIndexChanged(int)"), self.onNameComboBoxChanged)
self.layout().addRow("name:", self.nameComboBox)
nameIndex = self.model().index(0, 1, self.rootIndex())
self.nameComboBox.setIndex(nameIndex)
def __init__(self, parent = None, designMode = False):
TaurusWidget.__init__(self, parent, designMode)
self._macroIds = [] #list representing all macros ids (all from sequence) currently executed
self._sequencesPath = str(Qt.QDir.homePath())
self._sequenceModel = MacroSequenceTreeModel()
self.registerConfigProperty("sequencesPath", "setSequencesPath", "sequencesPath")
self.setLayout(Qt.QVBoxLayout())
self.layout().setContentsMargins(0,0,0,0)
splitter = Qt.QSplitter()
self.layout().addWidget(splitter)
splitter.setOrientation(Qt.Qt.Vertical)
sequenceEditor = TaurusWidget()
splitter.addWidget(sequenceEditor)
sequenceEditor.setUseParentModel(True)
sequenceEditor.setLayout(Qt.QVBoxLayout())
sequenceEditor.layout().setContentsMargins(0,0,0,0)
self.tree = MacroSequenceTree(sequenceEditor)
self.sequenceProxyModel = MacroSequenceProxyModel()
self.sequenceProxyModel.setSourceModel(self._sequenceModel)
self.tree.setModel(self.sequenceProxyModel)
self.tree.setItemDelegate(SequenceEditorDelegate(self.tree))
def createEditor(self, parent, option, index):
model = index.model()
taurus_role = model.role(index.column())
if taurus_role in (ChannelView.Channel, ChannelView.PlotType, ChannelView.Normalization,
ChannelView.Timer, ChannelView.Monitor, ChannelView.Trigger):
ret = Qt.QComboBox(parent)
elif taurus_role == ChannelView.PlotAxes:
item = index.internalPointer()
ptype = item.itemData()[1]['plot_type']
if ptype == PlotType.Spectrum:
n=1
elif ptype == PlotType.Image:
n=2
else:
return None
ret = AxesSelector(parent, n=n)
else:
ret = Qt.QStyledItemDelegate.createEditor(self, parent, option, index)
ret.setAutoFillBackground(True)
return ret
def __init__(self, parent=None, designMode=False):
TaurusWidget.__init__(self, parent, designMode)
self.setLayout(Qt.QGridLayout())
self.layout().setMargin(0)
self.layout().setSpacing(0)
self.btn_abort = Qt.QPushButton('Abort')
sizePolicy = Qt.QSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
self.btn_abort.setSizePolicy(sizePolicy)
self.door = None
self.btn_abort.setToolTip('Abort Macro')
self.layout().addWidget(self.btn_abort, 0, 0)
self.connect(self.btn_abort, Qt.SIGNAL('clicked()'), self.abort)
def _setupUI(self):
BasePage._setupUI(self)
self.setTitle('Panels editor')
self._label = Qt.QLabel("If you want extra panels add them to this list\n")
self._layout.addWidget(self._label,0,0)
self.setLayout(self._layout)
self._panelGroupBox = Qt.QGroupBox()
self._panelGroupBox.setCheckable(False)
self._panelGroupBox.setAlignment(Qt.Qt.AlignLeft)
self._panelGroupBox.setStyleSheet(" QGroupBox::title { subcontrol-position: top left; padding: 5 5px; }")
self._layout.addWidget(self._panelGroupBox,2,0,1,1)
self._horizontalLayout = Qt.QHBoxLayout(self._panelGroupBox)
self._panelList = Qt.QListWidget(self._panelGroupBox)
self._horizontalLayout.addWidget(self._panelList)
self._verticalLayout = Qt.QVBoxLayout()
self._addButton = Qt.QPushButton("Add Panel")
self._addButton.setStyleSheet("text-align: left;")
self._verticalLayout.addWidget(self._addButton)
self._removeButton = Qt.QPushButton("Remove Panel")
self._removeButton.setStyleSheet("text-align: left;")
self._verticalLayout.addWidget(self._removeButton)
self._upButton = Qt.QPushButton("Move Up")
self._upButton.setStyleSheet("text-align: left;")
self._verticalLayout.addWidget(self._upButton)
self._downButton = Qt.QPushButton("Move Down")
self._downButton.setStyleSheet("text-align: left;")
self._verticalLayout.addWidget(self._downButton)
self._horizontalLayout.addLayout(self._verticalLayout)
self._addButton.setIcon(taurus.qt.qtgui.resource.getThemeIcon("list-add"))
def _addEndMarker(self):
if self._endMacroMarkerEnabled:
m = Qwt5.QwtPlotMarker()
m.setLineStyle(m.VLine)
m.setXValue(self._currentpoint)
m.attach(self.parent())
pen = Qt.QPen(Qt.Qt.DashLine)
pen.setWidth(2)
m.setLinePen(pen)
self._endMarkers.append(m)
self._currentpoint -= 1
self.parent().replot()