Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def getElementTypeIcon(t):
if t == ChannelView.Channel:
return getIcon(":/actions/system-shutdown.svg")
elif t == ChannelView.Enabled:
return getIcon(":/status/true.svg")
elif t == ChannelView.Output:
return getThemeIcon("utilities-terminal")
elif t == ChannelView.PlotType:
return getIcon(":/apps/utilities-system-monitor.svg")
elif t == ChannelView.PlotAxes:
return getIcon(":/apps/utilities-system-monitor.svg")
elif t == ChannelView.Timer:
return getIcon(":/status/flag-green-clock.svg")
elif t == ChannelView.Monitor:
return getIcon(":/status/flag-green.svg")
elif t == ChannelView.Trigger:
return getIcon(":/actions/system-shutdown.svg")
elif t == ChannelView.NXPath:
return getThemeIcon("document-save-as")
return getIcon(":/tango.png")
elif role == Qt.Qt.DisplayRole:
value = None
rc = (index.row(), index.column())
if self._writeMode and rc in self._modifiedDict:
return self._modifiedDict[rc]
else:
value = tabledata[rc]
#cast the value to a standard python type
value = self.typeCastingMap[tabledata.dtype.kind](value)
return Qt.QVariant(value)
elif role == Qt.Qt.DecorationRole:
status = self.getStatus(index)
if (self._modifiedDict.has_key((index.row(), index.column()))) and (self._writeMode):
float_data = Qt.from_qvariant(self._modifiedDict[(index.row(), index.column())], float)
if self.inAlarmRange(float_data):
icon = getThemeIcon('document-save')
#return Qt.QVariant(Qt.QColor('blue'))
else:
icon = getThemeIcon('emblem-important')
#return Qt.QVariant(Qt.QColor('orange'))
return Qt.QVariant(icon)
elif role == Qt.Qt.EditRole:
value = None
if self._modifiedDict.has_key((index.row(), index.column())) and (self._writeMode):
value = self._modifiedDict[(index.row(), index.column())]
else:
value = tabledata[index.row(),index.column()]
if tabledata.dtype == bool:
value = bool(value)
return Qt.QVariant(value)
elif role == Qt.Qt.BackgroundRole:
if self._writeMode:
def __initPanelsMenu(self):
#Panels menu
self.__panelsMenu = Qt.QMenu('Panels', self)
self.menuBar().insertMenu(self.helpMenu.menuAction(), self.__panelsMenu)
self.hideAllPanelsAction = self.__panelsMenu.addAction(getIcon(':/actions/hide.svg'), "Hide all panels", self.hideAllPanels)
self.showAllPanelsAction = self.__panelsMenu.addAction(getIcon(':/actions/show.svg'), "Show all panels", self.showAllPanels)
self.newPanelAction = self.__panelsMenu.addAction(getThemeIcon("window-new"), "New Panel...", self.createCustomPanel)
self.removePanelAction = self.__panelsMenu.addAction(getThemeIcon("edit-clear"), "Remove Panel...", self.removePanel)
self.__panelsMenu.addAction(getThemeIcon("preferences-desktop-personal"), "Switch temporary/permanent status...", self.updatePermanentCustomPanels)
#temporary and permanent panels submenus
self.__panelsMenu.addSeparator()
self.__permPanelsMenu = Qt.QMenu('Permanent Panels', self)
self.__panelsMenu.addMenu(self.__permPanelsMenu)
self.connect(self.__permPanelsMenu, Qt.SIGNAL('aboutToShow()'), self.__updatePanelsMenu)
self.__tempPanelsMenu = Qt.QMenu('Temporary Panels', self)
self.__panelsMenu.addMenu(self.__tempPanelsMenu)
self.connect(self.__tempPanelsMenu, Qt.SIGNAL('aboutToShow()'), self.__updatePanelsMenu)
self.__panelsMenu.addSeparator()
def __init__(self, parent=None, initMacroServer=None, initDoor=None):
Qt.QDialog.__init__(self, parent)
self.initMacroServer = initMacroServer
self.initDoor = initDoor
configureAction = Qt.QAction(getThemeIcon("folder-open"), "Change custom macro editors paths", self)
self.connect(configureAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers)
configureAction.setToolTip("Change custom macro editors paths")
configureAction.setShortcut("F11")
self.refreshMacroServersAction = Qt.QAction(getThemeIcon("view-refresh"), "Reload macroservers", self)
self.connect(self.refreshMacroServersAction, Qt.SIGNAL("triggered()"), self.onReloadMacroServers)
self.refreshMacroServersAction.setToolTip("This will reload list of all macroservers from Tango DB")
self.refreshMacroServersAction.setShortcut("F5")
self.initComponents()
tip="Add new item",
triggered=self.onAdd)
self._removeAction = af.createAction(self, "Remove item",
icon=getThemeIcon("list-remove"),
tip="Remove item",
triggered=self.onRemove)
self._moveTopAction = af.createAction(self, "To top",
icon=getThemeIcon("go-top"),
tip="Move selected item to top",
triggered=self.onMoveTop)
self._moveUpAction = af.createAction(self, "Move up",
icon=getThemeIcon("go-up"),
tip="Move selected item up one level",
triggered=self.onMoveUp)
self._moveDownAction = af.createAction(self, "Move down",
icon=getThemeIcon("go-down"),
tip="Move selected item down one level",
triggered=self.onMoveDown)
self._moveBottomAction = af.createAction(self, "To bottom",
icon=getThemeIcon("go-bottom"),
tip="Move selected item to bottom",
triggered=self.onMoveBottom)
self.addAction(self._addAction)
self.addAction(self._removeAction)
self.addAction(self._moveTopAction)
self.addAction(self._moveUpAction)
self.addAction(self._moveDownAction)
self.addAction(self._moveBottomAction)
#self.setStyleSheet("QWidget {background : red; }")
src = str(src).strip()
if src == self._src:
return
self._src = src
#empty
if src == '':
self.display, self.icon, self.ok = '(Empty)', Qt.QIcon(),True
return
#for tango devices
try:
dev = taurus.Device(src)
if dev.isValidDev():
self.display, self.icon, self.ok = dev.getSimpleName(), getElementTypeIcon(TaurusElementType.Device), True
return
else:
self.display, self.icon, self.ok = src, getThemeIcon('network-error'),False
return
except:
#for tango attributes
try:
attr = taurus.Attribute(src)
dev = attr.getParentObj()
except TaurusException:
self.display, self.icon, self.ok = src, getThemeIcon('dialog-warning'), False
return
except Exception: #@todo: this catchall except is here as an emergency bugfix, but should probably be narrowed to PyTango DevFailed.
self.display, self.icon, self.ok = src, getThemeIcon('network-error'),False
return
if not dev.isValidDev():
self.display, self.icon, self.ok = src, getThemeIcon('network-error'),False
return
self.display, self.icon, self.ok = attr.getSimpleName(), getElementTypeIcon(TaurusElementType.Attribute),True
def __init__(self, view=None, parent=None, designMode=False):
BaseToolBar.__init__(self, name="Taurus refresh toolbar", view=view,
parent=parent, designMode=designMode)
af = ActionFactory()
self._refreshAction = af.createAction(self, "Refresh",
icon=getThemeIcon("view-refresh"),
tip="Refresh view",
triggered=self.onRefresh)
self.addAction(self._refreshAction)
taurus.qt.qtgui.resource.getThemeIcon("list-add"))
self._addRowButton.setText("Add Row ")
self._verticalLayout.addWidget(self._addRowButton)
self._removeRowButton = QtGui.QPushButton(self)
self._removeRowButton.setIcon(
taurus.qt.qtgui.resource.getThemeIcon("list-remove"))
self._removeRowButton.setText("Remove Row ")
self._verticalLayout.addWidget(self._removeRowButton)
self._addColumnButton = QtGui.QPushButton(self)
self._addColumnButton.setIcon(
taurus.qt.qtgui.resource.getThemeIcon("list-add"))
self._addColumnButton.setText("Add Column")
self._verticalLayout.addWidget(self._addColumnButton)
self._removeColumnButton = QtGui.QPushButton(self)
self._removeColumnButton.setIcon(
taurus.qt.qtgui.resource.getThemeIcon("list-remove"))
self._removeColumnButton.setText("Remove Column")
self._verticalLayout.addWidget(self._removeColumnButton)
self._upButton = QtGui.QPushButton(self)
self._upButton.setIcon(taurus.qt.qtgui.resource.getThemeIcon("go-up"))
self._upButton.setText("Move Up ")
self._verticalLayout.addWidget(self._upButton)
self._downButton = QtGui.QPushButton(self)
self._downButton.setIcon(
taurus.qt.qtgui.resource.getThemeIcon("go-down"))
self._downButton.setText("Move Down")
self._verticalLayout.addWidget(self._downButton)
spacerItem = QtGui.QSpacerItem(
20, 20, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding)
self._verticalLayout.addItem(spacerItem)
QtCore.QObject.connect(
if attr is None:
return src, pars['attributename'], getThemeIcon('network-error'),False
return src, attr.name(), getThemeIcon('network-server'),True
#for nexus files
m = re.match(NEXUS_SRC,src)
if m is not None:
host,path,nxpath,slice = m.group(4,5,9,10)
#@todo:open file and check the data is accessible
return src, nxpath, getThemeIcon('x-office-spreadsheet'), True
#for ascii files
m = re.match(ASCII_SRC,src)
if m is not None:
host,path, = m.group(4,5)
#@todo: open and check the file
#If nothing matches...
return src, src, getThemeIcon('dialog-warning'), False
spacerItem = Qt.QSpacerItem(0,0,Qt.QSizePolicy.Expanding,Qt.QSizePolicy.Fixed)
actionsLayout.addItem(spacerItem)
sequenceEditor.layout().addLayout(actionsLayout)
macroLayout = Qt.QHBoxLayout()
macroLayout.setContentsMargins(0,0,0,0)
macroLabel = Qt.QLabel("Macro:")
macroLayout.addWidget(macroLabel)
self.macroComboBox = MacroComboBox(self)
self.macroComboBox.setUseParentModel(True)
self.macroComboBox.setModelColumn(0)
self.macroComboBox.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)
macroLayout.addWidget(self.macroComboBox)
self.addMacroAction = Qt.QAction(getThemeIcon("list-add"), "Add macro...", self)
self.connect(self.addMacroAction, Qt.SIGNAL("triggered()"), self.onAdd)
self.addMacroAction.setToolTip("Clicking this button will add selected macro")
self.addMacroAction.setEnabled(False)
addButton = Qt.QToolButton()
addButton.setDefaultAction(self.addMacroAction)
macroLayout.addWidget(addButton)
sequenceEditor.layout().addLayout(macroLayout)
sequenceLayout = Qt.QHBoxLayout()
sequenceLayout.addWidget(self.tree)
layout = Qt.QVBoxLayout()
delButton = Qt.QToolButton()
delButton.setDefaultAction(self.tree.deleteAction)
delButton.setEnabled(False)