# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'home.ui'
#
# Created by: PyQt5 UI code generator 5.14.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
from boltiot import Bolt
class Ui_fan_2(object):
def setupUi(self, fan_2):
fan_2.setObjectName("fan_2")
fan_2.setWindowModality(QtCore.Qt.ApplicationModal)
fan_2.resize(1088, 799)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(fan_2.sizePolicy().hasHeightForWidth())
fan_2.setSizePolicy(sizePolicy)
fan_2.setLayoutDirection(QtCore.Qt.LeftToRight)
self.widget = QtWidgets.QWidget(fan_2)
self.widget.setGeometry(QtCore.QRect(140, 60, 781, 431))
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
self.widget.setSizePolicy(sizePolicy)
self.widget.setObjectName("widget")
self.gridLayout = QtWidgets.QGridLayout(self.widget)
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.gridLayout.setObjectName("gridLayout")
self.labelfan = QtWidgets.QLabel(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.labelfan.sizePolicy().hasHeightForWidth())
self.labelfan.setSizePolicy(sizePolicy)
self.labelfan.setMaximumSize(QtCore.QSize(29, 17))
self.labelfan.setObjectName("labelfan")
self.gridLayout.addWidget(self.labelfan, 0, 0, 1, 1)
self.fanon = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.fanon.sizePolicy().hasHeightForWidth())
self.fanon.setSizePolicy(sizePolicy)
self.fanon.setMaximumSize(QtCore.QSize(80, 25))
self.fanon.setObjectName("fanon")
self.gridLayout.addWidget(self.fanon, 0, 1, 1, 1)
self.fanoff = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.fanoff.sizePolicy().hasHeightForWidth())
self.fanoff.setSizePolicy(sizePolicy)
self.fanoff.setMaximumSize(QtCore.QSize(80, 25))
self.fanoff.setObjectName("fanoff")
self.gridLayout.addWidget(self.fanoff, 0, 2, 1, 1)
self.labellight = QtWidgets.QLabel(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.labellight.sizePolicy().hasHeightForWidth())
self.labellight.setSizePolicy(sizePolicy)
self.labellight.setMaximumSize(QtCore.QSize(42, 17))
self.labellight.setObjectName("labellight")
self.gridLayout.addWidget(self.labellight, 1, 0, 1, 1)
self.lighton = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lighton.sizePolicy().hasHeightForWidth())
self.lighton.setSizePolicy(sizePolicy)
self.lighton.setMaximumSize(QtCore.QSize(80, 25))
self.lighton.setObjectName("lighton")
self.gridLayout.addWidget(self.lighton, 1, 1, 1, 1)
self.lightoff = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lightoff.sizePolicy().hasHeightForWidth())
self.lightoff.setSizePolicy(sizePolicy)
self.lightoff.setMaximumSize(QtCore.QSize(80, 25))
self.lightoff.setObjectName("lightoff")
self.gridLayout.addWidget(self.lightoff, 1, 2, 1, 1)
self.labelextra = QtWidgets.QLabel(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.labelextra.sizePolicy().hasHeightForWidth())
self.labelextra.setSizePolicy(sizePolicy)
self.labelextra.setMaximumSize(QtCore.QSize(47, 17))
self.labelextra.setObjectName("labelextra")
self.gridLayout.addWidget(self.labelextra, 2, 0, 1, 1)
self.extraon = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.extraon.sizePolicy().hasHeightForWidth())
self.extraon.setSizePolicy(sizePolicy)
self.extraon.setMaximumSize(QtCore.QSize(80, 25))
self.extraon.setObjectName("extraon")
self.gridLayout.addWidget(self.extraon, 2, 1, 1, 1)
self.extraoff = QtWidgets.QPushButton(self.widget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Minimum)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.extraoff.sizePolicy().hasHeightForWidth())
self.extraoff.setSizePolicy(sizePolicy)
self.extraoff.setMaximumSize(QtCore.QSize(80, 25))
self.extraoff.setObjectName("extraoff")
self.gridLayout.addWidget(self.extraoff, 2, 2, 1, 1)
self.retranslateUi(fan_2)
self.fanon.clicked.connect(self.fanonclick)
self.fanoff.clicked.connect(self.fanoffclick)
self.lighton.clicked.connect(self.lightonclick)
self.lightoff.clicked.connect(self.lightoffclick)
self.extraon.clicked.connect(self.extraonclick)
self.extraoff.clicked.connect(self.extraoffclick)
QtCore.QMetaObject.connectSlotsByName(fan_2)
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialBegin(9600)
def extraonclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("5")
print(response)
def extraoffclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("6")
print(response)
def lightonclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("1")
print(response)
def lightoffclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("2")
print(response)
def fanonclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("3")
print(response)
def fanoffclick(self):
api_key ="91a27806-4174-4001-9d24-b42a37a3a513"
device_id = "BOLT5778783"
mybolt = Bolt(api_key, device_id)
response=mybolt.serialWrite("4")
print(response)
def retranslateUi(self, fan_2):
_translate = QtCore.QCoreApplication.translate
fan_2.setWindowTitle(_translate("fan_2", "Form"))
self.labelfan.setText(_translate("fan_2", "LIGHT"))
self.fanon.setText(_translate("fan_2", "OFF"))
self.fanoff.setText(_translate("fan_2", "ON"))
self.labellight.setText(_translate("fan_2", "FAN"))
self.lighton.setText(_translate("fan_2", "ON"))
self.lightoff.setText(_translate("fan_2", "OFF"))
self.labelextra.setText(_translate("fan_2", "EXTRA"))
self.extraon.setText(_translate("fan_2", "ON"))
self.extraoff.setText(_translate("fan_2", "OFF"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
fan_2 = QtWidgets.QWidget()
ui = Ui_fan_2()
ui.setupUi(fan_2)
fan_2.show()
sys.exit(app.exec_())
Comments
Please log in or sign up to comment.