Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_item_colors(self,emit = False):
item_colors = {}
try:
for item in self.scene().items():
if not getattr(item,'_name','') or not getattr(item,'_currBgBrush',None):
continue
item_colors[item._name] = item._currBgBrush.color().name()
if emit: self.emit(Qt.SIGNAL("itemsChanged"),self.modelName.split('/')[-1].split('.')[0],item_colors)
except:
self.warning('Unable to emitColors: %s'%traceback.format_exc())
return item_colors
if isinstance(node, macro.SingleParamNode):
node.setValue(Qt.from_qvariant(value, str))
self.emit(Qt.SIGNAL("dataChanged(QModelIndex,QModelIndex)"), index, index)
while True:
index = index.parent()
node = self.nodeFromIndex(index)
if isinstance(node, macro.MacroNode):
self.emit(Qt.SIGNAL("dataChanged(QModelIndex,QModelIndex)"), index, index.sibling(index.row(), self.columnCount(index)))
break
elif index.column() == 2:
progress = Qt.from_qvariant(value, float)
node.setProgress(progress)
self.emit(Qt.SIGNAL("dataChanged(QModelIndex,QModelIndex)"), index, index)
elif index.column() == 3:
node.setPause(Qt.from_qvariant(value, bool))
self.emit(Qt.SIGNAL("dataChanged(QModelIndex,QModelIndex)"), index, index)
return True
def onTextChanged(self):
self.emit(Qt.SIGNAL("modelChanged()"))
def deviceSelected(self,device_name=''):
'''QSIGNAL: this method is used to emit deviceSelected(QString) signal'''
self.trace("In TaurusDevTree.deviceSelected(%s)"%device_name)
try:
#item = self.currentItem()
device_name = device_name or self.getNodeDeviceName()#item.text(0)
if str(device_name).count('/')!=2: return
#Signal
self.trace('TaurusTree emit deviceSelected(%s) signal ...'%device_name)
self.emit(Qt.SIGNAL("deviceSelected(QString)"), Qt.QString(device_name))
except:
self.error(traceback.format_exc())
pass
buttonbox = Qt.QDialogButtonBox()
buttonbox.addButton(Qt.QPushButton('&Keep enabled'), buttonbox.RejectRole)
buttonbox.addButton(Qt.QPushButton('&Disable'), buttonbox.AcceptRole)
dlg.layout().addWidget(buttonbox)
dlg.connect(buttonbox, Qt.SIGNAL('accepted()'), dlg.accept)
dlg.connect(buttonbox, Qt.SIGNAL('rejected()'), dlg.reject)
dlg.layout().addWidget(rememberCB)
dlg.exec_()
#disable archiving if the user said so
if dlg.result() == dlg.Accepted:
self.setUseArchiving(False)
#restore the scale change notification only if the user chose to keep archiving AND did not want to disable warnings
else:
self.setUseArchiving(True)
if not rememberCB.isChecked():
self.connect(self.axisWidget(self.xBottom), Qt.SIGNAL("scaleDivChanged ()"), self._scaleChangeWarning)
def contextMenuEvent(self, event):
menu = self.createStandardContextMenu()
clearAction = Qt.QAction("Clear", menu)
menu.addAction(clearAction)
menu.addAction(self.stopAction)
if not len(self.toPlainText()):
clearAction.setEnabled(False)
Qt.QObject.connect(clearAction, Qt.SIGNAL("triggered()"), self.clear)
Qt.QObject.connect(self.stopAction, Qt.SIGNAL(
"toggled(bool)"), self.stopScrolling)
menu.exec_(event.globalPos())
def setIndex(self, index):
self._index = index
paramModel = index.model().nodeFromIndex(index)
self.setParamModel(paramModel)
self.connect(self, Qt.SIGNAL("modelChanged()"), self.onModelChanged)
self.setValue(paramModel.value())
#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()
if c.in_type != PyTango.CmdArgType.DevVoid:
self.debug('Adding arguments for command %s'%c.cmd_name)
pwidget = ParameterCB()
if c.cmd_name.lower() in self._defaultParameters:
for par in self._defaultParameters.get(c.cmd_name.lower(),[]): pwidget.addItem(par)
#pwidget.setEditable( (self._defaultParameters[c.cmd_name.lower()] or [''])[0] == '' )
if (self._defaultParameters[c.cmd_name.lower()] or [''])[0] == '':
pwidget.setEditable(True)
else:
pwidget.setEditable(False)
button.setParameters(self._defaultParameters[c.cmd_name.lower()][0])
self.connect(pwidget, Qt.SIGNAL('editTextChanged (const QString&)'),button.setParameters)
self.connect(pwidget, Qt.SIGNAL('currentIndexChanged (const QString&)'),button.setParameters)
self.connect(pwidget, Qt.SIGNAL('activated (int)'), button.setFocus)
self.connect(button, Qt.SIGNAL('commandExecuted'), pwidget.rememberCurrentText)
layout.addWidget(pwidget, row, 1)
self._paramWidgets.append(pwidget)
def __init__(self, qt_parent = None, designMode = False):
name = self.__class__.__name__
self.call__init__wo_kw(Qt.QLineEdit, qt_parent)
self.call__init__(TaurusBaseWritableWidget, name, designMode=designMode)
self._enableWheelEvent = False
self.__minAlarm = -float("inf")
self.__maxAlarm = float("inf")
self.__minLimit = -float("inf")
self.__maxLimit = float("inf")
self.setAlignment(Qt.Qt.AlignRight)
self.setValidator(None)
self.connect(self, Qt.SIGNAL('textChanged(const QString &)'), self.valueChanged)
self.connect(self, Qt.SIGNAL('returnPressed()'), self.writeValue)
self.connect(self, Qt.SIGNAL('valueChanged'), self.updatePendingOperations)
self.connect(self, Qt.SIGNAL('editingFinished()'), self._onEditingFinished)