def updateMaingrid(self): self.page0.setParent( None) #Deleting old page0. Garbagecollection doing it's work self.page0 = QtWidgets.QWidget(self.MainWindow) self.mainGrid = MainGrid(self.page0, self.devices) self.stackedWidget.insertWidget( 0, self.mainGrid.page0) # this changed right
def updateMaingrid(self, MainWindow): self.page0.setParent(None) self.page0 = QtWidgets.QWidget(MainWindow) self.mainGrid = MainGrid(self.page0, self.devices) self.stackedWidget.insertWidget(0, self.mainGrid.page0) # this changed right
def setupUi(self, mainWindow): stylesheetFile = "Stylesheet.css" #styling fh = open(stylesheetFile) qstr = str(fh.read()) self.MainWindow = mainWindow #assign mainwindow self.MainWindow.setStyleSheet(qstr) self.MainWindow.setObjectName("MainWindow") self.MainWindow.resize(1000, 650) #setup basic variables self.devices = [] self.currentDevice = None self.setupLog() self.mainQueue = Queue() self.lang = Language(0) #fill mainwindow self.centralwidget = QtWidgets.QWidget(self.MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(0, 0, 90, 650)) self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setContentsMargins(0, 0, 0, 0) self.verticalLayout.setObjectName("buttonBar") spacerItem = QtWidgets.QSpacerItem(20, 50, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum) self.verticalLayout.addItem(spacerItem) self.addADevice = QtWidgets.QPushButton(self.verticalLayoutWidget) self.addADevice.setObjectName("addADevice") self.addADevice.setFixedSize(90, 90) self.verticalLayout.addWidget(self.addADevice) self.Manual = QtWidgets.QPushButton(self.verticalLayoutWidget) self.Manual.setObjectName("Manual") self.Manual.setFixedSize(90, 90) self.verticalLayout.addWidget(self.Manual) self.Graphs = QtWidgets.QPushButton(self.verticalLayoutWidget) self.Graphs.setObjectName("Graphs") self.Graphs.setFixedSize(90, 90) self.verticalLayout.addWidget(self.Graphs) self.Settings = QtWidgets.QPushButton(self.verticalLayoutWidget) self.Settings.setObjectName("Settings") self.Settings.setFixedSize(90, 90) self.verticalLayout.addWidget(self.Settings) spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spacerItem1) self.Info = QtWidgets.QPushButton(self.verticalLayoutWidget) self.Info.setObjectName("Info") self.Info.setFixedSize(90, 90) self.verticalLayout.addWidget(self.Info) spacerItem2 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed) self.verticalLayout.addItem(spacerItem2) self.horizontalLayoutWidget = QtWidgets.QWidget(self.centralwidget) self.horizontalLayoutWidget.setGeometry(QtCore.QRect(90, 0, 910, 50)) self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalLayoutWidget) self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.Logo = QtWidgets.QLabel(self.horizontalLayoutWidget) self.Logo.setEnabled(True) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.Logo.sizePolicy().hasHeightForWidth()) self.Logo.setSizePolicy(sizePolicy) self.Logo.setMinimumSize(QtCore.QSize(0, 0)) self.Logo.setMaximumSize(QtCore.QSize(250, 50)) font = QtGui.QFont() font.setFamily("Calibri") font.setPointSize(16) font.setBold(True) font.setWeight(75) self.Logo.setFont(font) self.Logo.setAutoFillBackground(True) self.Logo.setFrameShape(QtWidgets.QFrame.Box) self.Logo.setFrameShadow(QtWidgets.QFrame.Raised) self.Logo.setObjectName("Logo") pic = QPixmap('rsz_1aerosdev') self.Logo.setPixmap(pic) self.horizontalLayout_2.addWidget(self.Logo) spacerItem3 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem3) self.fSkyTemp = QtWidgets.QFrame(self.horizontalLayoutWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.fSkyTemp.sizePolicy().hasHeightForWidth()) self.fSkyTemp.setSizePolicy(sizePolicy) self.fSkyTemp.setMinimumSize(QtCore.QSize(180, 100)) self.fSkyTemp.setFrameShape(QtWidgets.QFrame.StyledPanel) self.fSkyTemp.setFrameShadow(QtWidgets.QFrame.Raised) self.fSkyTemp.setObjectName("fSkyTemp") self.Sky = QtWidgets.QLabel(self.fSkyTemp) self.Sky.setGeometry(QtCore.QRect(10, 20, 75, 13)) self.Sky.setObjectName("Sky") self.TempUp = QtWidgets.QLabel(self.fSkyTemp) self.TempUp.setGeometry(QtCore.QRect(100, 20, 75, 13)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.TempUp.sizePolicy().hasHeightForWidth()) self.TempUp.setSizePolicy(sizePolicy) self.TempUp.setMinimumSize(QtCore.QSize(60, 0)) self.TempUp.setObjectName("TempUp") self.horizontalLayout_2.addWidget(self.fSkyTemp) spacerItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_2.addItem(spacerItem4) self.stackedWidget = QtWidgets.QStackedWidget(self.centralwidget) self.stackedWidget.setGeometry(QtCore.QRect(90, 50, 910, 600)) # self.stackedWidget.setMinimumSize(QtCore.QSize(600, 600)) #400, 400 # self.stackedWidget.move(100,100) # self.stackedWidget.setStyleSheet("background-color: black") # sets up maingrid and adds it to stacked widget self.page0 = QtWidgets.QWidget(self.MainWindow) self.mainGrid = MainGrid(self.page0, self.devices) self.stackedWidget.addWidget(self.mainGrid.page0) #sets up pages self.setupSettingsWindow() self.setupEnterDevice() self.setupGraphsWindow() self.setupManual() #sets starting page self.stackedWidget.setCurrentIndex(0) #binds functions to mainwindow buttons self.addADevice.clicked.connect(lambda: self.setIndex(2)) self.Manual.clicked.connect(lambda: self.setIndex(4)) self.Graphs.clicked.connect(lambda: self.setIndex(3)) self.Settings.clicked.connect(lambda: self.setIndex(1)) self.Info.clicked.connect(self.showInfo) QtCore.QMetaObject.connectSlotsByName(self.MainWindow) self.MainWindow.setCentralWidget(self.centralwidget) self.retranslateUi(0)
def updatestatus(self): for widgetLong in self.devices: widgetName = widgetLong.name widgetStatus = widgetLong.getStatus MainGrid.setStatus(widgetName, widgetStatus)