Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _setupUI(self):
BasePage._setupUI(self)
self.setTitle('Custom logo')
self._label = Qt.QLabel(
"\nIf you want to have a custom logo inside your application panel, please select the image file. \n")
self._label.setWordWrap(True)
self._layout.addWidget(self._label, 0, 0, 1, 4)
self._customLogoLabel = Qt.QLabel("Custom logo:")
self._customLogoLineEdit = Qt.QLineEdit()
self._customLogoLineEdit.setMinimumSize(250, 25)
self._customLogoLineEdit.setReadOnly(False)
self._customLogoButton = Qt.QPushButton()
self._customLogoButton.setToolTip("Browse...")
self._customLogoButton.setIcon(Qt.QIcon.fromTheme("folder-open"))
self._customLogoButton.setMaximumSize(80, 25)
self._spacerItem1 = Qt.QSpacerItem(
30, 30, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Fixed)
self._customLogo = Qt.QLabel(self)
self._customLogo.setAlignment(Qt.Qt.AlignCenter)
self._customLogo.setMinimumSize(120, 120)
self._deviceMemberEdit = Qt.QLineEdit()
self._deviceClass = Qt.QLineEdit()
self._serverEdit = Qt.QLineEdit()
self._serverNameEdit = Qt.QLineEdit()
self._serverInstanceEdit = Qt.QLineEdit()
self._attributeEdit = Qt.QLineEdit()
lbl = Qt.QLabel("Device type:")
l.addWidget(lbl, 1, 0)
l.setAlignment(lbl, Qt.Qt.AlignRight)
l.addWidget(self._deviceClass, 1, 1)
l.addWidget(Qt.QLabel("Device:"), 2, 0)
l.addWidget(self._deviceEdit, 2, 1)
l.addWidget(Qt.QLabel("Device domain:"), 3, 0)
l.addWidget(self._deviceDomainEdit, 3, 1)
l.addWidget(Qt.QLabel("Device family:"), 4, 0)
l.addWidget(self._deviceFamilyEdit, 4, 1)
l.addWidget(Qt.QLabel("Device member:"), 5, 0)
l.addWidget(self._deviceMemberEdit, 5, 1)
l.addWidget(Qt.QLabel("Server:"), 6, 0)
l.addWidget(self._serverEdit, 6, 1)
l.addWidget(Qt.QLabel("Server name:"), 7, 0)
l.addWidget(self._serverNameEdit, 7, 1)
l.addWidget(Qt.QLabel("Server instance:"), 8, 0)
l.addWidget(self._serverInstanceEdit, 8, 1)
l.addWidget(Qt.QLabel("Attribute:"), 9, 0)
l.addWidget(self._attributeEdit, 9, 1)
self._serverInstanceEdit = Qt.QLineEdit()
self._attributeEdit = Qt.QLineEdit()
lbl = Qt.QLabel("Device type:")
l.addWidget(lbl, 1, 0)
l.setAlignment(lbl, Qt.Qt.AlignRight)
l.addWidget(self._deviceClass, 1, 1)
l.addWidget(Qt.QLabel("Device:"), 2, 0)
l.addWidget(self._deviceEdit, 2, 1)
l.addWidget(Qt.QLabel("Device domain:"), 3, 0)
l.addWidget(self._deviceDomainEdit, 3, 1)
l.addWidget(Qt.QLabel("Device family:"), 4, 0)
l.addWidget(self._deviceFamilyEdit, 4, 1)
l.addWidget(Qt.QLabel("Device member:"), 5, 0)
l.addWidget(self._deviceMemberEdit, 5, 1)
l.addWidget(Qt.QLabel("Server:"), 6, 0)
l.addWidget(self._serverEdit, 6, 1)
l.addWidget(Qt.QLabel("Server name:"), 7, 0)
l.addWidget(self._serverNameEdit, 7, 1)
l.addWidget(Qt.QLabel("Server instance:"), 8, 0)
l.addWidget(self._serverInstanceEdit, 8, 1)
l.addWidget(Qt.QLabel("Attribute:"), 9, 0)
l.addWidget(self._attributeEdit, 9, 1)
self.argEdit = Qt.QLineEdit()
self.w_arg.layout().addWidget(self.argEdit, 1, col)
_argEditors.append(self.argEdit)
for e, v in zip(_argEditors, d_values):
if v is None:
continue
e.setText(str(v))
# Create bottom layout
self.mb = MacroButton()
self.mb.setModel(door_name)
self.w_bottom = Qt.QWidget()
self.w_bottom.setLayout(Qt.QGridLayout())
self.w_bottom.layout().addWidget(self.mb, 0, 0, 2, 7)
self.w_bottom.layout().addWidget(Qt.QLabel('Result:'), 2, 0)
self.result_label = Qt.QLabel()
self.w_bottom.layout().addWidget(self.result_label, 2, 1, 1, 5)
self.show_progress = Qt.QCheckBox('Progress')
self.show_progress.setChecked(True)
self.w_bottom.layout().addWidget(self.show_progress, 3, 0)
mb_abort = TaurusCommandButton(command='StopMacro',
icon=':/actions/media_playback_stop.svg')
mb_abort.setModel(door_name)
self.w_bottom.layout().addWidget(mb_abort, 3, 1)
# Toggle progressbar
self.show_progress.stateChanged.connect(self.toggle_progress)
# connect the argument editors
def __init__(self, parent=None, ledsize=LedSize.SMALL,
ledcolor=LedColor.GREEN):
Qt.QLabel.__init__(self, parent)
self.ledsize = ledsize
self.status = LedStatus.OFF
self.ledcolor = ledcolor
self.setObjectName("Led")
sizePolicy = Qt.QSizePolicy(
Qt.QSizePolicy.Policy(0), Qt.QSizePolicy.Policy(0))
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
self.setSizePolicy(sizePolicy)
# no need to call changeColor. changeSize calls it for us
self.changeSize(ledsize)
for cname in self.defaultCandidates + list(customWidgets):
if cname in available or '.' in cname:
row.append(cname)
if cname not in pixmaps:
pixmaps[cname] = getCachedPixmap('snapshot:%s.png' % cname)
if len(row) == 3:
choices.append(row)
row = []
row.append(self.OTHER_TXT)
choices.append(row)
# defaultPixmap=getPixmap('logos:taurus.png')
self.choiceWidget = GraphicalChoiceWidget(
choices=choices, pixmaps=pixmaps)
self.widgetTypeLB = Qt.QLabel("<b>Widget Type:</b>")
self.choiceWidget.choiceMade.connect(self.onChoiceMade)
layout = Qt.QVBoxLayout()
layout.addLayout(nameLayout)
layout.addWidget(self.choiceWidget)
layout.addWidget(self.widgetTypeLB)
self.setLayout(layout)
def setText_(self, text):
"""Method to expose QLabel.setText"""
Qt.QLabel.setText(self, text)
def updateReadWidget(self):
# get the class for the widget and replace it if necessary
try:
klass = self.readWidgetClassFactory(self.readWidgetClassID)
self._readWidget = self._newSubwidget(self._readWidget, klass)
except Exception as e:
self._destroyWidget(self._readWidget)
self._readWidget = Qt.QLabel('[Error]')
msg = 'Error creating read widget:\n' + str(e)
self._readWidget.setToolTip(msg)
self.debug(msg)
# self.traceback(30) #warning level=30
# take care of the layout
self.addReadWidgetToLayout()
if self._readWidget is not None:
# give the new widget a reference to its buddy TaurusValue object
self._readWidget.taurusValueBuddy = weakref.ref(self)
if isinstance(self._readWidget, TaurusReadWriteSwitcher):
self._readWidget.readWidget.taurusValueBuddy = weakref.ref(
self)
self._readWidget.writeWidget.taurusValueBuddy = weakref.ref(
self)
l.addWidget(self._deviceClass, 1, 1)
l.addWidget(Qt.QLabel("Device:"), 2, 0)
l.addWidget(self._deviceEdit, 2, 1)
l.addWidget(Qt.QLabel("Device domain:"), 3, 0)
l.addWidget(self._deviceDomainEdit, 3, 1)
l.addWidget(Qt.QLabel("Device family:"), 4, 0)
l.addWidget(self._deviceFamilyEdit, 4, 1)
l.addWidget(Qt.QLabel("Device member:"), 5, 0)
l.addWidget(self._deviceMemberEdit, 5, 1)
l.addWidget(Qt.QLabel("Server:"), 6, 0)
l.addWidget(self._serverEdit, 6, 1)
l.addWidget(Qt.QLabel("Server name:"), 7, 0)
l.addWidget(self._serverNameEdit, 7, 1)
l.addWidget(Qt.QLabel("Server instance:"), 8, 0)
l.addWidget(self._serverInstanceEdit, 8, 1)
l.addWidget(Qt.QLabel("Attribute:"), 9, 0)
l.addWidget(self._attributeEdit, 9, 1)
panelLayout.addWidget(titleBar, 0)
l = Qt.QHBoxLayout()
l.setMargin(2)
l.setSpacing(2)
self._titleBar.setLayout(l)
self._titleButton = Qt.QToolButton()
self._titleButton.setStyleSheet("border: 0px")
styleOption = Qt.QStyleOption()
styleOption.initFrom(self._titleButton)
style = Qt.QApplication.style()
icon = style.standardIcon(
Qt.QStyle.SP_DesktopIcon, styleOption, self._titleButton)
self._titleButton.setIcon(icon)
self._titleLabel = Qt.QLabel()
self._upDownButton = Qt.QToolButton()
self._upDownButton.setStyleSheet("border: 0px")
self._upDownButton.clicked.connect(self.switchContentVisible)
l.addWidget(self._titleButton, 0)
l.addWidget(self._titleLabel, 1)
l.addWidget(self._upDownButton, 0)
self._content = content = ContentFrame()
l = Qt.QHBoxLayout()
l.setContentsMargins(0, 0, 0, 0)
content.setLayout(l)
panelLayout.addWidget(content, 1)