def importarAction(self, d: device): self.txtNombre.setText("%s-Copia" % d.nombre) self.txtID.setText(d.id) self.txtToken.setText(d.token) self.txtTime.setValue(d.time) self.lblImagen.setPixmap(Logica.byteArrayToImage(d.image)) self.dispositivo.image = d.image
def expresion(self,value): from classes import Logica if value == "" or value == "null" or value == '' or value is None: self.__expresion = None return if not Logica.evaluarExpresion(value) : raise ValueError("¡Error! \"%s\" no es una expresion valida\nLa expresion debe ser logica y contener solo a x" % value) self.__expresion = value
def actualizarImagen(self, event): from PyQt5.QtCore import QByteArray, QFileInfo from PyQt5.QtWidgets import QFileDialog, QMessageBox fileName = QFileDialog.getOpenFileName( self, "Abrir", filter="Images (*.png *.jpg)" ) # options=QtWidgets.QFileDialog.DontUseNativeDialog if all(fileName): info = QFileInfo(fileName[0]) if info.size() > 32000: QMessageBox.warning(self, "¡Error!", "No se permite archivos de mas de 32kb") return str_base64 = Logica.imageToByteArray(fileName[0]) if str_base64 is None: QMessageBox.warning(self, "¡Error!", "Fallo al cargar la imagen") return self.lblImagen.setPixmap(Logica.byteArrayToImage(str_base64)) self.dispositivo.image = str_base64
def actualizarVariables_Callback( self, variablesList: list): # callback for worker if isinstance(variablesList, Exception): # No connection with API SCADA self.deviceSignals.error.emit(variablesList) self.updateDeviceState("Sin Conexion") else: if len(variablesList) == 0: self.deviceSignals.error.emit( Exception( "No hay acceso a internet")) # No Internet connection self.updateDeviceState("Desconectado", "red") else: for v in variablesList: if not v.expresion is None: v.value = Logica.evaluarExpresion(v.expresion, v.value) if not v.notify is None: # If notify option is active if Logica.evaluarExpresion( v.notify.replace("-", "").strip(), v.value): # evaluate if condition is true self.nuevoReporte(v) self.__variablesContainer[v.unicID].updateUI(v) self.updateDeviceState("Conectado", "green") self.Last.setText( datetime.now().strftime("%d/%m/%Y %I:%M:%S %p")) self.__dispostivo.lastUpdate = datetime.now().strftime( "%d/%m/%Y %I:%M:%S %p") for i, var in enumerate(self.__dispostivo.variables ): # to update his value if var.unicID == v.unicID: self.__dispostivo.variables[i].value = v.value if len( list( filter(lambda var: (not var.output), self.__dispostivo.variables))) == 0: self.updateState("¡No hay variables!", subText=None) self.__status = 0 else: self.updateState("Actualizando en ", subText=str(self.__dispostivo.time)) self.__status = 1 self.deviceSignals.updated.emit()
def updateUI(self, dev: device): self.__dispostivo = dev _translate = QtCore.QCoreApplication.translate self.Container.setTitle( _translate("DispositivoWidget", self.__dispostivo.nombre)) self.lblImagen.setPixmap( Logica.byteArrayToImage(self.__dispostivo.image)) if self.__status == 2: # if updating then wait untill finish and update self.deviceSignals.updated.connect(self.updateVariables) return self.updateVariables()
def showEvent(self, evt): json = Logica.LeerConfiguracionesLocal() if json is None: QMessageBox.warning( self, "¡Error!", "¡Error! no se pudo leer el archivo de configuracion") self.btnAceptar.setEnabled(False) return self.txtIPLocal.setText(json["Host"]) self.txtPuertoLocal.setText( "" if json["Port"] is None else json["Port"].__str__()) self.checkSSL.setChecked(True if json["HTTP_PROTOCOL"] == "https" else False)
def exportarReportes(self): from PyQt5.QtWidgets import QFileDialog, QMessageBox if len(self.reportes) == 0: QMessageBox.information(self, "¡Aviso!", "No hay nada que exportar") return fileName = QFileDialog.getSaveFileName( self, "Abrir", filter="Excel files (*.xlsx)" ) # options=QtWidgets.QFileDialog.DontUseNativeDialog if all(fileName): response = Logica.ExportarReportes(filename=fileName[0], reportes=self.reportes) if response is False: QMessageBox.warning(self, "¡Error!", "Fallo al guardar") return QMessageBox.information(self, "¡Exito!", "Exportado exitosamente")
def importarDispositivos(self): from PyQt5.QtWidgets import QFileDialog, QMessageBox from uuid import uuid4 fileName = QFileDialog.getOpenFileName( self, "Abrir", filter="JSON files (*.json)" ) # options=QtWidgets.QFileDialog.DontUseNativeDialog if all(fileName): response = Logica.fileToJSON(fileName[0]) if response is None: QMessageBox.warning(self, "¡Error!", "Fallo al cargar") return for dev in response: dev["UnicID"] = uuid4().__str__( ) # Generates a new unicID for each device for i, var in enumerate(dev["Variables"]): dev["Variables"][i]["UnicID"] = uuid4().__str__( ) # and each var to avoid any duplicate problem self.agregarDispositivoAction(dev) # adds to current workspace self.mostrarDispositivoAction(dev) # show into the devices modals
def exportarDispositivos(self): from PyQt5.QtWidgets import QFileDialog, QMessageBox from copy import copy c = self.comboBox.itemData(self.comboBox.currentIndex()) if len(c.workSpace.devices) == 0: QMessageBox.information( self, "¡Aviso!", "No hay nada que exportar en este proyecto") return tempWork = (copy(c.workSpace)).toJSON( ) # makes and copy to delete their image to save space for i, dev in enumerate(tempWork["Drivers"]): tempWork["Drivers"][i]["Image"] = None fileName = QFileDialog.getSaveFileName( self, "Abrir", filter="JSON files (*.json)" ) # options=QtWidgets.QFileDialog.DontUseNativeDialog if all(fileName): response = Logica.JSONToFile(fileName[0], tempWork["Drivers"]) if response is False: QMessageBox.warning(self, "¡Error!", "Fallo al guardar") return QMessageBox.information(self, "¡Exito!", "Exportado exitosamente") del tempWork # deletes the copy
def btnAceptar_Click(self): api = API() try: api.IP = self.txtIPLocal.text() api.puerto = None if self.txtPuertoLocal.text( ) == "" else self.txtPuertoLocal.text() api.HTTP_PROTOCOL = "https" if self.checkSSL.isChecked( ) else "http" except ValueError as vError: QMessageBox.warning(self, "¡Error!", str(vError)) return response = QMessageBox.question( self, "¡Confirmacion!", "¿Seguro que desea guardar estas configuraciones?\nCualquier error podria provocar que la applicacion no se ejecute correctamente" ) if response == QMessageBox.Yes: result = Logica.GuardarConfiguracionesLocal(api.toJSON()) if result: QMessageBox.information( self, "¡Aviso!", "¡Exito! Configuracion actualizada\nTendra efecto la proxima vez que inicie la app" ) self.close()
def setupUi(self): DispositivoWidget = self DispositivoWidget.setObjectName("DispositivoWidget") DispositivoWidget.setWindowModality(QtCore.Qt.WindowModal) DispositivoWidget.resize(612, 186) DispositivoWidget.setStyleSheet( "background-color: rgb(255, 255, 255);") self.ProjectFrame = QtWidgets.QFrame(DispositivoWidget) self.ProjectFrame.setGeometry(QtCore.QRect(0, 0, 612, 182)) self.ProjectFrame.setMinimumSize(QtCore.QSize(350, 182)) self.ProjectFrame.setMaximumSize(QtCore.QSize(16777215, 200)) self.ProjectFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.ProjectFrame.setFrameShadow(QtWidgets.QFrame.Sunken) self.ProjectFrame.setObjectName("ProjectFrame") self.lblImagen = QtWidgets.QLabel(self.ProjectFrame) self.lblImagen.setGeometry(QtCore.QRect(10, 15, 171, 151)) self.lblImagen.setText("") self.lblImagen.setPixmap(QtGui.QPixmap(":/source/img/NoImage.png")) self.lblImagen.setScaledContents(True) self.lblImagen.setObjectName("lblImagen") self.InfoFrame = QtWidgets.QFrame(self.ProjectFrame) self.InfoFrame.setGeometry(QtCore.QRect(180, 10, 325, 165)) self.InfoFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.InfoFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.InfoFrame.setLineWidth(0) self.InfoFrame.setObjectName("InfoFrame") self.lblNombre = QtWidgets.QLabel(self.InfoFrame) self.lblNombre.setGeometry(QtCore.QRect(5, 10, 85, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblNombre.setFont(font) self.lblNombre.setLineWidth(0) self.lblNombre.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblNombre.setObjectName("lblNombre") self.lblID = QtWidgets.QLabel(self.InfoFrame) self.lblID.setGeometry(QtCore.QRect(5, 40, 85, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblID.setFont(font) self.lblID.setLineWidth(0) self.lblID.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblID.setObjectName("lblID") self.lblToken = QtWidgets.QLabel(self.InfoFrame) self.lblToken.setGeometry(QtCore.QRect(5, 75, 85, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblToken.setFont(font) self.lblToken.setLineWidth(0) self.lblToken.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblToken.setObjectName("lblToken") self.lblTiempo = QtWidgets.QLabel(self.InfoFrame) self.lblTiempo.setGeometry(QtCore.QRect(5, 115, 85, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblTiempo.setFont(font) self.lblTiempo.setLineWidth(0) self.lblTiempo.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblTiempo.setObjectName("lblTiempo") self.lblVariables = QtWidgets.QLabel(self.InfoFrame) self.lblVariables.setGeometry(QtCore.QRect(5, 140, 85, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariables.setFont(font) self.lblVariables.setLineWidth(0) self.lblVariables.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblVariables.setObjectName("lblVariables") self.ScrollNombre = QtWidgets.QScrollArea(self.InfoFrame) self.ScrollNombre.setGeometry(QtCore.QRect(100, 10, 200, 22)) self.ScrollNombre.setMinimumSize(QtCore.QSize(110, 20)) self.ScrollNombre.setMaximumSize(QtCore.QSize(200, 25)) self.ScrollNombre.setFrameShape(QtWidgets.QFrame.Panel) self.ScrollNombre.setFrameShadow(QtWidgets.QFrame.Plain) self.ScrollNombre.setLineWidth(0) self.ScrollNombre.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.ScrollNombre.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.ScrollNombre.setWidgetResizable(True) self.ScrollNombre.setObjectName("ScrollNombre") self.NombreScrollLayout = QtWidgets.QWidget() self.NombreScrollLayout.setGeometry(QtCore.QRect(0, 0, 186, 36)) self.NombreScrollLayout.setObjectName("NombreScrollLayout") self.vboxlayout = QtWidgets.QVBoxLayout(self.NombreScrollLayout) self.vboxlayout.setContentsMargins(0, 0, 0, 0) self.vboxlayout.setSpacing(0) self.vboxlayout.setObjectName("vboxlayout") self.txtNombre = QtWidgets.QLabel(self.NombreScrollLayout) self.txtNombre.setMaximumSize(QtCore.QSize(16666672, 16666672)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.txtNombre.setFont(font) self.txtNombre.setLineWidth(0) self.txtNombre.setTextFormat(QtCore.Qt.PlainText) self.txtNombre.setScaledContents(True) self.txtNombre.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.txtNombre.setWordWrap(True) self.txtNombre.setIndent(5) self.txtNombre.setObjectName("txtNombre") self.vboxlayout.addWidget(self.txtNombre) self.ScrollNombre.setWidget(self.NombreScrollLayout) self.ScrollID = QtWidgets.QScrollArea(self.InfoFrame) self.ScrollID.setGeometry(QtCore.QRect(100, 43, 210, 24)) self.ScrollID.setMinimumSize(QtCore.QSize(110, 20)) self.ScrollID.setMaximumSize(QtCore.QSize(215, 100)) self.ScrollID.setFrameShape(QtWidgets.QFrame.Panel) self.ScrollID.setFrameShadow(QtWidgets.QFrame.Plain) self.ScrollID.setLineWidth(0) self.ScrollID.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) self.ScrollID.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) self.ScrollID.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustIgnored) self.ScrollID.setWidgetResizable(False) self.ScrollID.setObjectName("ScrollID") self.IDScrollLayout = QtWidgets.QWidget() self.IDScrollLayout.setGeometry(QtCore.QRect(0, 0, 207, 18)) self.IDScrollLayout.setObjectName("IDScrollLayout") self._2 = QtWidgets.QVBoxLayout(self.IDScrollLayout) self._2.setContentsMargins(0, 0, 0, 0) self._2.setSpacing(0) self._2.setObjectName("_2") self.txtID = QtWidgets.QLabel(self.IDScrollLayout) self.txtID.setMaximumSize(QtCore.QSize(16666672, 16666672)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) font.setKerning(True) self.txtID.setFont(font) self.txtID.setLineWidth(0) self.txtID.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.txtID.setWordWrap(True) self.txtID.setIndent(-8) self.txtID.setObjectName("txtID") self._2.addWidget(self.txtID) self.ScrollID.setWidget(self.IDScrollLayout) self.ScrollToken = QtWidgets.QScrollArea(self.InfoFrame) self.ScrollToken.setGeometry(QtCore.QRect(100, 80, 190, 32)) self.ScrollToken.setMinimumSize(QtCore.QSize(110, 20)) self.ScrollToken.setMaximumSize(QtCore.QSize(225, 100)) self.ScrollToken.setFrameShape(QtWidgets.QFrame.Panel) self.ScrollToken.setFrameShadow(QtWidgets.QFrame.Plain) self.ScrollToken.setLineWidth(0) self.ScrollToken.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.ScrollToken.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.ScrollToken.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustToContents) self.ScrollToken.setWidgetResizable(False) self.ScrollToken.setObjectName("ScrollToken") self.TokencrollLayout = QtWidgets.QWidget() self.TokencrollLayout.setGeometry(QtCore.QRect(0, 0, 280, 18)) self.TokencrollLayout.setObjectName("TokencrollLayout") self._3 = QtWidgets.QVBoxLayout(self.TokencrollLayout) self._3.setContentsMargins(0, 0, 0, 0) self._3.setSpacing(0) self._3.setObjectName("_3") self.txtToken = QtWidgets.QLabel(self.TokencrollLayout) self.txtToken.setMaximumSize(QtCore.QSize(16666672, 16666672)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.txtToken.setFont(font) self.txtToken.setLineWidth(0) self.txtToken.setTextFormat(QtCore.Qt.RichText) self.txtToken.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.txtToken.setWordWrap(True) self.txtToken.setIndent(-8) self.txtToken.setObjectName("txtToken") self._3.addWidget(self.txtToken) self.ScrollToken.setWidget(self.TokencrollLayout) self.txtTiempo = QtWidgets.QLabel(self.InfoFrame) self.txtTiempo.setGeometry(QtCore.QRect(100, 115, 150, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.txtTiempo.setFont(font) self.txtTiempo.setObjectName("txtTiempo") self.txtVariables = QtWidgets.QLabel(self.InfoFrame) self.txtVariables.setGeometry(QtCore.QRect(100, 140, 150, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.txtVariables.setFont(font) self.txtVariables.setObjectName("txtVariables") self.utilsFrame = QtWidgets.QFrame(self.ProjectFrame) self.utilsFrame.setGeometry(QtCore.QRect(510, 10, 91, 165)) self.utilsFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.utilsFrame.setFrameShadow(QtWidgets.QFrame.Raised) self.utilsFrame.setLineWidth(0) self.utilsFrame.setObjectName("utilsFrame") self.btnEditar = QtWidgets.QPushButton(self.utilsFrame) self.btnEditar.setGeometry(QtCore.QRect(10, 70, 38, 38)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnEditar.sizePolicy().hasHeightForWidth()) self.btnEditar.setSizePolicy(sizePolicy) self.btnEditar.setMinimumSize(QtCore.QSize(0, 0)) self.btnEditar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnEditar.setFont(font) self.btnEditar.setText("") icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/source/img/Editar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnEditar.setIcon(icon) self.btnEditar.setIconSize(QtCore.QSize(24, 24)) self.btnEditar.setShortcut("") self.btnEditar.setCheckable(False) self.btnEditar.setFlat(True) self.btnEditar.setObjectName("btnEditar") self.btnEliminar = QtWidgets.QPushButton(self.utilsFrame) self.btnEliminar.setGeometry(QtCore.QRect(50, 70, 38, 38)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnEliminar.sizePolicy().hasHeightForWidth()) self.btnEliminar.setSizePolicy(sizePolicy) self.btnEliminar.setMinimumSize(QtCore.QSize(0, 0)) self.btnEliminar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnEliminar.setFont(font) self.btnEliminar.setText("") icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(":/source/img/Cancelar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnEliminar.setIcon(icon1) self.btnEliminar.setIconSize(QtCore.QSize(24, 24)) self.btnEliminar.setShortcut("") self.btnEliminar.setCheckable(False) self.btnEliminar.setFlat(True) self.btnEliminar.setObjectName("btnEliminar") self.btnCopiar = QtWidgets.QPushButton(self.utilsFrame) self.btnCopiar.setGeometry(QtCore.QRect(60, 10, 24, 24)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnCopiar.sizePolicy().hasHeightForWidth()) self.btnCopiar.setSizePolicy(sizePolicy) self.btnCopiar.setMinimumSize(QtCore.QSize(0, 0)) self.btnCopiar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnCopiar.setFont(font) self.btnCopiar.setText("") icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/source/img/Copiar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnCopiar.setIcon(icon2) self.btnCopiar.setIconSize(QtCore.QSize(24, 24)) self.btnCopiar.setShortcut("") self.btnCopiar.setCheckable(False) self.btnCopiar.setFlat(True) self.btnCopiar.setObjectName("btnCopiar") self.retranslateUi(DispositivoWidget) QtCore.QMetaObject.connectSlotsByName(DispositivoWidget) self.lblImagen.setPixmap( Logica.byteArrayToImage(self.dispositivo.image)) #listener self.btnEditar.clicked.connect(self.btnEditar_Click) self.btnEliminar.clicked.connect(self.btnEliminar_Click) self.btnCopiar.clicked.connect(self.btnCopiar_Click) if self.IsImport: self.btnEliminar.hide() self.btnCopiar.hide() self.btnEditar.setGeometry(23, 60, 48, 48) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/source/img/Importar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnEditar.setIcon(icon)
def setupUI(self): AgregarDispositvoModal = self AgregarDispositvoModal.setObjectName("AgregarDispositvoModal") AgregarDispositvoModal.setWindowModality(QtCore.Qt.WindowModal) AgregarDispositvoModal.resize(560, 640) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( AgregarDispositvoModal.sizePolicy().hasHeightForWidth()) AgregarDispositvoModal.setSizePolicy(sizePolicy) AgregarDispositvoModal.setMinimumSize(QtCore.QSize(560, 640)) font = QtGui.QFont() font.setFamily("Noto Serif") font.setPointSize(11) font.setBold(True) font.setWeight(75) AgregarDispositvoModal.setFont(font) AgregarDispositvoModal.setContextMenuPolicy(QtCore.Qt.NoContextMenu) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(":/source/img/if_16_1751363.ico"), QtGui.QIcon.Normal, QtGui.QIcon.Off) AgregarDispositvoModal.setWindowIcon(icon) AgregarDispositvoModal.setStyleSheet( "background-color: rgb(255, 255, 255);") AgregarDispositvoModal.setInputMethodHints(QtCore.Qt.ImhSensitiveData) self.verticalLayout = QtWidgets.QVBoxLayout(AgregarDispositvoModal) self.verticalLayout.setObjectName("verticalLayout") self.MainFrame = QtWidgets.QFrame(AgregarDispositvoModal) self.MainFrame.setMinimumSize(QtCore.QSize(360, 520)) self.MainFrame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.MainFrame.setFrameShadow(QtWidgets.QFrame.Raised) self.MainFrame.setObjectName("MainFrame") self.MainLayout = QtWidgets.QVBoxLayout(self.MainFrame) self.MainLayout.setContentsMargins(0, 0, 0, 20) self.MainLayout.setSpacing(0) self.MainLayout.setObjectName("MainLayout") self.TitleFrame = QtWidgets.QFrame(self.MainFrame) self.TitleFrame.setMinimumSize(QtCore.QSize(0, 111)) self.TitleFrame.setMaximumSize(QtCore.QSize(16777215, 111)) self.TitleFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.TitleFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.TitleFrame.setObjectName("TitleFrame") self.TitleLayout = QtWidgets.QGridLayout(self.TitleFrame) self.TitleLayout.setContentsMargins(0, 0, 0, 0) self.TitleLayout.setSpacing(0) self.TitleLayout.setObjectName("TitleLayout") self.lblUDB = QtWidgets.QLabel(self.TitleFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lblUDB.sizePolicy().hasHeightForWidth()) self.lblUDB.setSizePolicy(sizePolicy) self.lblUDB.setMinimumSize(QtCore.QSize(0, 116)) self.lblUDB.setMaximumSize(QtCore.QSize(16777215, 116)) self.lblUDB.setStyleSheet("background-color: rgb(65, 105, 225);\n" "margin:0px;") self.lblUDB.setFrameShape(QtWidgets.QFrame.NoFrame) self.lblUDB.setText("") self.lblUDB.setPixmap(QtGui.QPixmap(":/source/img/logo.png")) self.lblUDB.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblUDB.setObjectName("lblUDB") self.TitleLayout.addWidget(self.lblUDB, 0, 0, 1, 1) self.lblSCADA = QtWidgets.QLabel(self.TitleFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lblSCADA.sizePolicy().hasHeightForWidth()) self.lblSCADA.setSizePolicy(sizePolicy) self.lblSCADA.setMinimumSize(QtCore.QSize(250, 116)) self.lblSCADA.setMaximumSize(QtCore.QSize(16777215, 116)) font = QtGui.QFont() font.setPointSize(21) font.setBold(True) font.setWeight(75) self.lblSCADA.setFont(font) self.lblSCADA.setAutoFillBackground(False) self.lblSCADA.setStyleSheet( "color: rgb(255, 255, 0);background-color: rgb(65, 105, 225);\n" "margin:0px;") self.lblSCADA.setObjectName("lblSCADA") self.TitleLayout.addWidget(self.lblSCADA, 0, 2, 1, 1) self.ExitFrame = QtWidgets.QFrame(self.TitleFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Minimum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.ExitFrame.sizePolicy().hasHeightForWidth()) self.ExitFrame.setSizePolicy(sizePolicy) self.ExitFrame.setMinimumSize(QtCore.QSize(0, 116)) self.ExitFrame.setMaximumSize(QtCore.QSize(16777215, 116)) self.ExitFrame.setStyleSheet("background-color: rgb(65, 105, 225);") self.ExitFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.ExitFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.ExitFrame.setLineWidth(0) self.ExitFrame.setObjectName("ExitFrame") self.ExitLayout = QtWidgets.QGridLayout(self.ExitFrame) self.ExitLayout.setContentsMargins(0, 0, 0, 0) self.ExitLayout.setSpacing(0) self.ExitLayout.setObjectName("ExitLayout") self.btnExit = QtWidgets.QPushButton(self.ExitFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnExit.sizePolicy().hasHeightForWidth()) self.btnExit.setSizePolicy(sizePolicy) self.btnExit.setMaximumSize(QtCore.QSize(32, 32)) self.btnExit.setLayoutDirection(QtCore.Qt.RightToLeft) self.btnExit.setText("") icon1 = QtGui.QIcon() icon1.addPixmap(QtGui.QPixmap(":/source/img/Cancelar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnExit.setIcon(icon1) self.btnExit.setIconSize(QtCore.QSize(24, 24)) self.btnExit.setFlat(True) self.btnExit.setObjectName("btnExit") self.ExitLayout.addWidget(self.btnExit, 0, 1, 1, 1) self.lblIIE = QtWidgets.QLabel(self.ExitFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Maximum, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lblIIE.sizePolicy().hasHeightForWidth()) self.lblIIE.setSizePolicy(sizePolicy) self.lblIIE.setMaximumSize(QtCore.QSize(16777215, 116)) self.lblIIE.setStyleSheet("background-color: rgb(65, 105, 225);\n" "margin:0px;") self.lblIIE.setText("") self.lblIIE.setPixmap(QtGui.QPixmap(":/source/img/iiie.png")) self.lblIIE.setScaledContents(False) self.lblIIE.setAlignment(QtCore.Qt.AlignCenter) self.lblIIE.setObjectName("lblIIE") self.ExitLayout.addWidget(self.lblIIE, 0, 0, 2, 1) self.TitleLayout.addWidget(self.ExitFrame, 0, 3, 1, 1) self.MainLayout.addWidget(self.TitleFrame, 0, QtCore.Qt.AlignTop) self.lblTitle = QtWidgets.QLabel(self.MainFrame) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Maximum) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.lblTitle.sizePolicy().hasHeightForWidth()) self.lblTitle.setSizePolicy(sizePolicy) self.lblTitle.setMinimumSize(QtCore.QSize(0, 26)) self.lblTitle.setMaximumSize(QtCore.QSize(16777215, 51)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(14) font.setBold(True) font.setWeight(75) self.lblTitle.setFont(font) self.lblTitle.setStyleSheet("margin-top:5px;") self.lblTitle.setAlignment(QtCore.Qt.AlignCenter) self.lblTitle.setObjectName("lblTitle") self.MainLayout.addWidget(self.lblTitle, 0, QtCore.Qt.AlignTop) self.InformacionContent = QtWidgets.QGroupBox(self.MainFrame) self.InformacionContent.setMinimumSize(QtCore.QSize(0, 215)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.InformacionContent.setFont(font) self.InformacionContent.setStyleSheet( "QGroupBox{margin-left:25px;margin-right:25px;}\n" "QGroupBox::title{top:0;}") self.InformacionContent.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.InformacionContent.setFlat(False) self.InformacionContent.setObjectName("InformacionContent") self.lblImagen = QtWidgets.QLabel(self.InformacionContent) self.lblImagen.setGeometry(QtCore.QRect(40, 42, 171, 151)) self.lblImagen.setText("") self.lblImagen.setPixmap(QtGui.QPixmap(":/source/img/NoImage.png")) self.lblImagen.setScaledContents(True) self.lblImagen.setObjectName("lblImagen") self.txtNombre = QtWidgets.QLineEdit(self.InformacionContent) self.txtNombre.setGeometry(QtCore.QRect(320, 60, 161, 21)) self.txtNombre.setStyleSheet( "border-bottom:1px solid black;border-top:none;") self.txtNombre.setObjectName("txtNombre") self.txtID = QtWidgets.QLineEdit(self.InformacionContent) self.txtID.setGeometry(QtCore.QRect(320, 90, 161, 21)) self.txtID.setStyleSheet( "border-bottom:1px solid black;border-top:none;") self.txtID.setObjectName("txtID") self.txtToken = QtWidgets.QLineEdit(self.InformacionContent) self.txtToken.setGeometry(QtCore.QRect(320, 120, 161, 21)) self.txtToken.setStyleSheet( "border-bottom:1px solid black;border-top:none;") self.txtToken.setObjectName("txtToken") self.txtTime = QtWidgets.QSpinBox(self.InformacionContent) self.txtTime.setGeometry(QtCore.QRect(320, 155, 45, 26)) self.txtTime.setObjectName("txtTime") self.txtTime.setMinimum(1) self.txtTime.setValue(30) self.label = QtWidgets.QLabel(self.InformacionContent) self.label.setGeometry(QtCore.QRect(250, 63, 61, 20)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label.setObjectName("label") self.label_2 = QtWidgets.QLabel(self.InformacionContent) self.label_2.setGeometry(QtCore.QRect(250, 93, 54, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.label_2.setFont(font) self.label_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.InformacionContent) self.label_3.setGeometry(QtCore.QRect(250, 125, 54, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.label_3.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(self.InformacionContent) self.label_4.setGeometry(QtCore.QRect(250, 160, 54, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.label_4.setFont(font) self.label_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.label_4.setObjectName("label_4") self.btnAceptar = QtWidgets.QPushButton(self.InformacionContent) self.btnAceptar.setGeometry(QtCore.QRect(410, 3, 95, 40)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnAceptar.sizePolicy().hasHeightForWidth()) self.btnAceptar.setSizePolicy(sizePolicy) self.btnAceptar.setMinimumSize(QtCore.QSize(92, 38)) self.btnAceptar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnAceptar.setFont(font) self.btnAceptar.setStyleSheet("border:1px solid green;top:0px;") icon2 = QtGui.QIcon() icon2.addPixmap(QtGui.QPixmap(":/source/img/OK.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnAceptar.setIcon(icon2) self.btnAceptar.setIconSize(QtCore.QSize(24, 24)) self.btnAceptar.setShortcut("") self.btnAceptar.setCheckable(False) self.btnAceptar.setFlat(True) self.btnAceptar.setObjectName("btnAceptar") self.btnImportar = QtWidgets.QPushButton(self.InformacionContent) self.btnImportar.setGeometry(QtCore.QRect(310, 3, 95, 40)) self.btnImportar.setMinimumSize(QtCore.QSize(92, 38)) self.btnImportar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnImportar.setFont(font) self.btnImportar.setStyleSheet("border:1px solid green;") icon3 = QtGui.QIcon() icon3.addPixmap(QtGui.QPixmap(":/source/img/Importar-SM.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnImportar.setIcon(icon3) self.btnImportar.setIconSize(QtCore.QSize(24, 24)) self.btnImportar.setShortcut("") self.btnImportar.setCheckable(False) self.btnImportar.setFlat(True) self.btnImportar.setObjectName("btnImportar") self.MainLayout.addWidget(self.InformacionContent) spacerItem = QtWidgets.QSpacerItem( 40, 20, QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Minimum) self.MainLayout.addItem(spacerItem) self.VariablesContent = QtWidgets.QGroupBox(self.MainFrame) self.VariablesContent.setMinimumSize(QtCore.QSize(0, 225)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.VariablesContent.setFont(font) self.VariablesContent.setStyleSheet( "QGroupBox{margin-left:25px;margin-right:25px;}\n" "QGroupBox::title{top:0;}") self.VariablesContent.setObjectName("VariablesContent") self.lblVariablesCount = QtWidgets.QLabel(self.VariablesContent) self.lblVariablesCount.setGeometry(QtCore.QRect(300, 13, 101, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariablesCount.setFont(font) self.lblVariablesCount.setObjectName("lblVariablesCount") self.btnVariableAgregar = QtWidgets.QPushButton(self.VariablesContent) self.btnVariableAgregar.setGeometry(QtCore.QRect(410, 0, 95, 40)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.btnVariableAgregar.sizePolicy().hasHeightForWidth()) self.btnVariableAgregar.setSizePolicy(sizePolicy) self.btnVariableAgregar.setMinimumSize(QtCore.QSize(92, 38)) self.btnVariableAgregar.setMaximumSize(QtCore.QSize(128, 48)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.btnVariableAgregar.setFont(font) self.btnVariableAgregar.setStyleSheet( "border:1px solid green;top:0px;") icon4 = QtGui.QIcon() icon4.addPixmap(QtGui.QPixmap(":/source/img/Agregar.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off) self.btnVariableAgregar.setIcon(icon4) self.btnVariableAgregar.setIconSize(QtCore.QSize(24, 24)) self.btnVariableAgregar.setShortcut("") self.btnVariableAgregar.setCheckable(False) self.btnVariableAgregar.setFlat(True) self.btnVariableAgregar.setObjectName("btnVariableAgregar") self.variablesScroll = QtWidgets.QScrollArea(self.VariablesContent) self.variablesScroll.setGeometry(QtCore.QRect(28, 70, 481, 151)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Ignored) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.variablesScroll.sizePolicy().hasHeightForWidth()) self.variablesScroll.setSizePolicy(sizePolicy) self.variablesScroll.setMinimumSize(QtCore.QSize(481, 150)) self.variablesScroll.setFrameShape(QtWidgets.QFrame.NoFrame) self.variablesScroll.setLineWidth(0) self.variablesScroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.variablesScroll.setWidgetResizable(True) self.variablesScroll.setObjectName("variablesScroll") self.VariableScrollContent = QtWidgets.QWidget() self.VariableScrollContent.setGeometry(QtCore.QRect(0, 0, 481, 151)) self.VariableScrollContent.setObjectName("VariableScrollContent") self.VariablesLayout = QtWidgets.QVBoxLayout( self.VariableScrollContent) self.VariablesLayout.setContentsMargins(5, 5, 9, -1) self.VariablesLayout.setObjectName("VariablesLayout") self.VariablesLayout.setAlignment(Qt.AlignTop) self.VariablesLayout.setSpacing(5) self.variablesScroll.setWidget(self.VariableScrollContent) self.lblVariableNombre = QtWidgets.QLabel(self.VariablesContent) self.lblVariableNombre.setGeometry(QtCore.QRect(45, 45, 65, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariableNombre.setFont(font) self.lblVariableNombre.setObjectName("lblVariableNombre") self.lblVariablePIN = QtWidgets.QLabel(self.VariablesContent) self.lblVariablePIN.setGeometry(QtCore.QRect(125, 45, 65, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariablePIN.setFont(font) self.lblVariablePIN.setObjectName("lblVariablePIN") self.lblVariableTipo = QtWidgets.QLabel(self.VariablesContent) self.lblVariableTipo.setGeometry(QtCore.QRect(210, 45, 41, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariableTipo.setFont(font) self.lblVariableTipo.setObjectName("lblVariableTipo") self.lblVariableColor = QtWidgets.QLabel(self.VariablesContent) self.lblVariableColor.setGeometry(QtCore.QRect(288, 45, 41, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariableColor.setFont(font) self.lblVariableColor.setObjectName("lblVariableColor") self.lblVariableSenal = QtWidgets.QLabel(self.VariablesContent) self.lblVariableSenal.setGeometry(QtCore.QRect(363, 45, 51, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariableSenal.setFont(font) self.lblVariableSenal.setObjectName("lblVariableSenal") self.lblVariableAccion = QtWidgets.QLabel(self.VariablesContent) self.lblVariableAccion.setGeometry(QtCore.QRect(422, 45, 65, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(11) font.setBold(True) font.setWeight(75) self.lblVariableAccion.setFont(font) self.lblVariableAccion.setObjectName("lblVariableAccion") self.MainLayout.addWidget(self.VariablesContent) self.verticalLayout.addWidget(self.MainFrame, 0, QtCore.Qt.AlignTop) self.retranslateUi(AgregarDispositvoModal) QtCore.QMetaObject.connectSlotsByName(AgregarDispositvoModal) self.center() # listener self.parent.signals.resize.connect(self.center) self.btnExit.clicked.connect(self.exit) self.lblImagen.mouseDoubleClickEvent = self.actualizarImagen self.btnVariableAgregar.clicked.connect(self.agregarVariable) self.btnAceptar.clicked.connect(self.btnAceptar_Click) self.btnImportar.clicked.connect(self.btnImportar_Click) if self.IsEdit: self.txtNombre.setText(self.dispositivo.nombre) self.txtID.setText(self.dispositivo.id) self.txtToken.setText(self.dispositivo.token) self.txtTime.setValue(self.dispositivo.time) self.lblImagen.setPixmap( Logica.byteArrayToImage(self.dispositivo.image)) self.btnImportar.hide() self.lblTitle.setText("Editar Dispositivo") self.shortcut = QtWidgets.QShortcut(Qt.Key_Return, self) self.shortcut.activated.connect(self.btnAceptar_Click) self.mostrarVariables()
def setupUi(self): DispositivoWidget = self DispositivoWidget.setObjectName("DispositivoWidget") DispositivoWidget.setWindowModality(QtCore.Qt.WindowModal) DispositivoWidget.resize(330, 200) DispositivoWidget.setGeometry(self.__dispostivo.x, self.__dispostivo.y, 330, 200) DispositivoWidget.setMinimumSize(QtCore.QSize(330, 200)) self.MainFrame = QtWidgets.QFrame(DispositivoWidget) self.MainFrame.setGeometry(QtCore.QRect(0, 0, 330, 200)) self.MainFrame.setStyleSheet("background-color: rgb(255, 255, 255);") self.MainFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.MainFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.MainFrame.setObjectName("MainFrame") self.Container = QtWidgets.QGroupBox(self.MainFrame) self.Container.setGeometry(QtCore.QRect(0, 0, 329, 199)) font = QtGui.QFont() font.setFamily("Roboto") font.setBold(True) font.setWeight(75) self.Container.setFont(font) self.Container.setObjectName("Container") self.lblImagen = QtWidgets.QLabel(self.Container) self.lblImagen.setGeometry(QtCore.QRect(10, 50, 120, 115)) self.lblImagen.setFrameShape(QtWidgets.QFrame.Panel) self.lblImagen.setLineWidth(0) self.lblImagen.setText("") self.lblImagen.setPixmap( Logica.byteArrayToImage(self.__dispostivo.image)) self.lblImagen.setScaledContents(True) self.lblImagen.setObjectName("lblImagen") self.StatusFrame = QtWidgets.QFrame(self.Container) self.StatusFrame.setGeometry(QtCore.QRect(5, 20, 321, 24)) self.StatusFrame.setFrameShape(QtWidgets.QFrame.NoFrame) self.StatusFrame.setFrameShadow(QtWidgets.QFrame.Plain) self.StatusFrame.setLineWidth(0) self.StatusFrame.setObjectName("StatusFrame") self.lblStatus = QtWidgets.QLabel(self.StatusFrame) self.lblStatus.setGeometry(QtCore.QRect(10, 5, 45, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.lblStatus.setFont(font) self.lblStatus.setFrameShadow(QtWidgets.QFrame.Sunken) self.lblStatus.setObjectName("lblStatus") self.lblTime = QtWidgets.QLabel(self.StatusFrame) self.lblTime.setGeometry(QtCore.QRect(170, 5, 115, 16)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.lblTime.setFont(font) self.lblTime.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignTrailing | QtCore.Qt.AlignVCenter) self.lblTime.setObjectName("lblTime") self.Time = QtWidgets.QLabel(self.StatusFrame) self.Time.setGeometry(QtCore.QRect(285, 0, 24, 24)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.Time.setFont(font) self.Time.setLineWidth(0) self.Time.setText("") self.Time.setTextFormat(QtCore.Qt.PlainText) self.Time.setScaledContents(True) self.Time.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.Time.setObjectName("Time") self.Status = QtWidgets.QLabel(self.StatusFrame) self.Status.setGeometry(QtCore.QRect(71, 5, 90, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.Status.setFont(font) self.Status.setStyleSheet("color:gray;") self.Status.setFrameShadow(QtWidgets.QFrame.Sunken) self.Status.setAlignment(QtCore.Qt.AlignLeading | QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.Status.setObjectName("Status") self.StatusCircle = QtWidgets.QLabel(self.StatusFrame) self.StatusCircle.setGeometry(QtCore.QRect(56, 8, 12, 12)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.StatusCircle.setFont(font) self.StatusCircle.setStyleSheet( "background-color:gray;border-radius:5px;") self.StatusCircle.setFrameShadow(QtWidgets.QFrame.Sunken) self.StatusCircle.setMidLineWidth(1) self.StatusCircle.setText("") self.StatusCircle.setObjectName("StatusCircle") self.lblLast = QtWidgets.QLabel(self.Container) self.lblLast.setGeometry(QtCore.QRect(10, 175, 70, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.lblLast.setFont(font) self.lblLast.setFrameShadow(QtWidgets.QFrame.Sunken) self.lblLast.setObjectName("lblLast") self.Last = QtWidgets.QLabel(self.Container) self.Last.setGeometry(QtCore.QRect(78, 175, 171, 17)) font = QtGui.QFont() font.setFamily("Roboto") font.setPointSize(10) font.setBold(True) font.setWeight(75) self.Last.setFont(font) self.Last.setFrameShadow(QtWidgets.QFrame.Sunken) self.Last.setTextFormat(QtCore.Qt.RichText) self.Last.setObjectName("Last") self.VariablesScroll = QtWidgets.QScrollArea(self.Container) self.VariablesScroll.setGeometry(QtCore.QRect(140, 50, 175, 120)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.VariablesScroll.sizePolicy().hasHeightForWidth()) self.VariablesScroll.setSizePolicy(sizePolicy) self.VariablesScroll.setMinimumSize(QtCore.QSize(175, 115)) self.VariablesScroll.setLineWidth(0) self.VariablesScroll.setVerticalScrollBarPolicy( QtCore.Qt.ScrollBarAsNeeded) self.VariablesScroll.setHorizontalScrollBarPolicy( QtCore.Qt.ScrollBarAlwaysOff) self.VariablesScroll.setSizeAdjustPolicy( QtWidgets.QAbstractScrollArea.AdjustToContents) self.VariablesScroll.setWidgetResizable(False) self.VariablesScroll.setFrameShape(QtWidgets.QFrame.NoFrame) self.VariablesScroll.setObjectName("VariablesScroll") self.VariablesFrame = QtWidgets.QWidget() self.VariablesFrame.setGeometry(QtCore.QRect(0, 0, 175, 115)) sizePolicy = QtWidgets.QSizePolicy( QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.VariablesFrame.sizePolicy().hasHeightForWidth()) self.VariablesFrame.setSizePolicy(sizePolicy) self.VariablesFrame.setMinimumSize(QtCore.QSize(175, 115)) self.VariablesFrame.setSizeIncrement(QtCore.QSize(0, 0)) self.VariablesFrame.setObjectName("VariablesFrame") self.verticalLayout = QtWidgets.QVBoxLayout(self.VariablesFrame) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setSpacing(5) self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout.setAlignment(Qt.AlignTop) self.VariablesScroll.setWidget(self.VariablesFrame) self.movie = QMovie(":/source/img/Cargando.gif") self.movie.setScaledSize(QtCore.QSize(64, 64)) self.retranslateUi(DispositivoWidget) QtCore.QMetaObject.connectSlotsByName(DispositivoWidget) self.show() if len(self.__dispostivo.variables) == 0 or len( list( filter(lambda var: (not var.output), self.__dispostivo.variables))) == 0: self.lblTime.setText("¡No hay variables!") self.Time.hide() else: timer.signals.time_elapsed.connect( self.time) # Signal emitted each second self.__status = 1 self.lblImagen.mouseDoubleClickEvent = self.actualizarImagen for var in self.__dispostivo.variables: self.mostrarVariable(var) if (len(self.__dispostivo.variables) * 25) > 115: self.VariablesFrame.setGeometry( 0, 0, 175, len(self.__dispostivo.variables) * 25)