
from PyQt5 import QtCore, QtGui, QtWidgets
from utilities import *

 
class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(910, 627)
        font = QtGui.QFont()
        font.setPointSize(14)
        MainWindow.setFont(font)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.frame = QtWidgets.QFrame(self.centralwidget)
        self.frame.setGeometry(QtCore.QRect(80, 110, 741, 401))
        font = QtGui.QFont()
        font.setPointSize(10)
        self.frame.setFont(font)
        self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame.setObjectName("frame")
        self.label_1_1 = QtWidgets.QLabel(self.frame)
        self.label_1_1.setGeometry(QtCore.QRect(40, 30, 100, 40))
        self.label_1_1.setWordWrap(True)
        self.label_1_1.setObjectName("label_1_1")
        self.label_1_2 = QtWidgets.QLabel(self.frame)
        self.label_1_2.setGeometry(QtCore.QRect(40, 100, 100, 100))
        self.label_1_2.setWordWrap(True)
        self.label_1_2.setObjectName("label_1_2")
        self.label_2_1 = QtWidgets.QLabel(self.frame)
        self.label_2_1.setGeometry(QtCore.QRect(410, 30, 100, 40))
        self.label_2_1.setWordWrap(True)
        self.label_2_1.setObjectName("label_2_1")
        self.label_2_2 = QtWidgets.QLabel(self.frame)
        self.label_2_2.setGeometry(QtCore.QRect(410, 100, 110, 80))
        self.label_2_2.setWordWrap(True)
        self.label_2_2.setObjectName("label_2_2")
        self.textBrowser_1_1 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_1_1.setEnabled(False)
        self.textBrowser_1_1.setGeometry(QtCore.QRect(160, 30, 160, 40))
        self.textBrowser_1_1.setObjectName("textBrowser_1_1")
        self.textBrowser_1_2 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_1_2.setEnabled(False)
        self.textBrowser_1_2.setGeometry(QtCore.QRect(160, 120, 160, 40))
        self.textBrowser_1_2.setObjectName("textBrowser_1_2")
        self.textBrowser_2_2 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_2_2.setEnabled(False)
        self.textBrowser_2_2.setGeometry(QtCore.QRect(540, 120, 160, 40))
        self.textBrowser_2_2.setObjectName("textBrowser_2_2")
        self.textBrowser_2_1 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_2_1.setEnabled(False)
        self.textBrowser_2_1.setGeometry(QtCore.QRect(540, 30, 160, 40))
        self.textBrowser_2_1.setObjectName("textBrowser_2_1")
        self.comboBox_1_3 = QtWidgets.QComboBox(self.frame)
        self.comboBox_1_3.setGeometry(QtCore.QRect(60, 220, 240, 40))
        self.comboBox_1_3.setToolTip("")
        self.comboBox_1_3.setEditable(False)
        self.comboBox_1_3.setObjectName("comboBox_1_3")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_1_3.addItem("")
        self.comboBox_2_3 = QtWidgets.QComboBox(self.frame)
        self.comboBox_2_3.setGeometry(QtCore.QRect(440, 220, 240, 40))
        self.comboBox_2_3.setEditable(False)
        self.comboBox_2_3.setObjectName("comboBox_2_3")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.comboBox_2_3.addItem("")
        self.textBrowser_1_3 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_1_3.setEnabled(False)
        self.textBrowser_1_3.setGeometry(QtCore.QRect(100, 290, 160, 40))
        self.textBrowser_1_3.setObjectName("textBrowser_1_3")
        self.textBrowser_2_3 = QtWidgets.QTextBrowser(self.frame)
        self.textBrowser_2_3.setEnabled(False)
        self.textBrowser_2_3.setGeometry(QtCore.QRect(480, 290, 160, 40))
        self.textBrowser_2_3.setObjectName("textBrowser_2_3")
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setGeometry(QtCore.QRect(270, 10, 421, 31))
        self.label.setObjectName("label")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)
  

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_1_1.setText(_translate("MainWindow", "Current Temperature"))
        self.label_1_2.setText(_translate("MainWindow", "Average Temperature for the whole day"))
        self.label_2_1.setText(_translate("MainWindow", "Current Light Intensity"))
        self.label_2_2.setText(_translate("MainWindow", "Average Light Intensity for the whole day"))
        self.comboBox_1_3.setItemText(0, _translate("MainWindow", "Avg Temp for below hrs"))
        self.comboBox_1_3.setItemText(1, _translate("MainWindow", "00-01"))
        self.comboBox_1_3.setItemText(2, _translate("MainWindow", "01-02"))
        self.comboBox_1_3.setItemText(3, _translate("MainWindow", "02-03"))
        self.comboBox_1_3.setItemText(4, _translate("MainWindow", "03-04"))
        self.comboBox_1_3.setItemText(5, _translate("MainWindow", "04-05"))
        self.comboBox_1_3.setItemText(6, _translate("MainWindow", "05-06"))
        self.comboBox_1_3.setItemText(7, _translate("MainWindow", "06-07"))
        self.comboBox_1_3.setItemText(8, _translate("MainWindow", "07-08"))
        self.comboBox_1_3.setItemText(9, _translate("MainWindow", "08-09"))
        self.comboBox_1_3.setItemText(10, _translate("MainWindow", "09-10"))
        self.comboBox_1_3.setItemText(11, _translate("MainWindow", "10-11"))
        self.comboBox_1_3.setItemText(12, _translate("MainWindow", "11-12"))
        self.comboBox_1_3.setItemText(13, _translate("MainWindow", "12-13"))
        self.comboBox_1_3.setItemText(14, _translate("MainWindow", "13-14"))
        self.comboBox_1_3.setItemText(15, _translate("MainWindow", "14-15"))
        self.comboBox_1_3.setItemText(16, _translate("MainWindow", "15-16"))
        self.comboBox_1_3.setItemText(17, _translate("MainWindow", "16-17"))
        self.comboBox_1_3.setItemText(18, _translate("MainWindow", "17-18"))
        self.comboBox_1_3.setItemText(19, _translate("MainWindow", "18-19"))
        self.comboBox_1_3.setItemText(20, _translate("MainWindow", "19-20"))
        self.comboBox_1_3.setItemText(21, _translate("MainWindow", "20-21"))
        self.comboBox_1_3.setItemText(22, _translate("MainWindow", "21-22"))
        self.comboBox_1_3.setItemText(23, _translate("MainWindow", "22-23"))
        self.comboBox_1_3.setItemText(24, _translate("MainWindow", "23-00"))
        self.comboBox_2_3.setItemText(0, _translate("MainWindow", "Avg Temp for below hrs"))
        self.comboBox_2_3.setItemText(1, _translate("MainWindow", "00-01"))
        self.comboBox_2_3.setItemText(2, _translate("MainWindow", "01-02"))
        self.comboBox_2_3.setItemText(3, _translate("MainWindow", "02-03"))
        self.comboBox_2_3.setItemText(4, _translate("MainWindow", "03-04"))
        self.comboBox_2_3.setItemText(5, _translate("MainWindow", "04-05"))
        self.comboBox_2_3.setItemText(6, _translate("MainWindow", "05-06"))
        self.comboBox_2_3.setItemText(7, _translate("MainWindow", "06-07"))
        self.comboBox_2_3.setItemText(8, _translate("MainWindow", "07-08"))
        self.comboBox_2_3.setItemText(9, _translate("MainWindow", "08-09"))
        self.comboBox_2_3.setItemText(10, _translate("MainWindow", "09-10"))
        self.comboBox_2_3.setItemText(11, _translate("MainWindow", "10-11"))
        self.comboBox_2_3.setItemText(12, _translate("MainWindow", "11-12"))
        self.comboBox_2_3.setItemText(13, _translate("MainWindow", "12-13"))
        self.comboBox_2_3.setItemText(14, _translate("MainWindow", "13-14"))
        self.comboBox_2_3.setItemText(15, _translate("MainWindow", "14-15"))
        self.comboBox_2_3.setItemText(16, _translate("MainWindow", "15-16"))
        self.comboBox_2_3.setItemText(17, _translate("MainWindow", "16-17"))
        self.comboBox_2_3.setItemText(18, _translate("MainWindow", "17-18"))
        self.comboBox_2_3.setItemText(19, _translate("MainWindow", "18-19"))
        self.comboBox_2_3.setItemText(20, _translate("MainWindow", "19-20"))
        self.comboBox_2_3.setItemText(21, _translate("MainWindow", "20-21"))
        self.comboBox_2_3.setItemText(22, _translate("MainWindow", "21-22"))
        self.comboBox_2_3.setItemText(23, _translate("MainWindow", "22-23"))
        self.comboBox_2_3.setItemText(24, _translate("MainWindow", "23-00"))
        self.label.setText(_translate("MainWindow", "Room Condition Monitoring System"))
        
        self.textBrowser_1_2.setText(_translate("MainWindow", str(findAvg()[0]) ))
        self.textBrowser_1_3.setText(_translate("MainWindow", "" ))

        self.textBrowser_2_2.setText(_translate("MainWindow", str(findAvg()[1]) ))
        self.textBrowser_2_3.setText(_translate("MainWindow", "" ))
        self.comboBox_1_3.currentTextChanged.connect(self.onSelected_1_3)
        self.comboBox_2_3.currentTextChanged.connect(self.onSelected_2_3)

    def getData(self, MainWindow ,last_temp,last_light):
        _translate = QtCore.QCoreApplication.translate
        self.textBrowser_1_1.setText(_translate("MainWindow", str(last_temp) ))
        self.textBrowser_2_1.setText(_translate("MainWindow", str(last_light) ))



    def onSelected_1_3(self,index):
        _translate = QtCore.QCoreApplication.translate
        i = self.comboBox_1_3.currentText()[:2]
        var = findAvg_hrs(str(i))[0]
        self.textBrowser_1_3.setText(_translate("MainWindow", str(var) ))

    def onSelected_2_3(self,index):
        _translate = QtCore.QCoreApplication.translate
        i = self.comboBox_2_3.currentText()[:2]
        var = findAvg_hrs(str(i))[1]
        self.textBrowser_2_3.setText(_translate("MainWindow", str(var) ))

