物联网python996655

这里写自定义目录标题

https://service-arf7cs90-1321789174.gz.apigw.tencentcs.com/release/zcc

物联网采集信息并显示

博客设置页面,选择一款你喜欢的代码片高亮样式,下面展示同样高亮的 代码片.

// An highlighted block



import json
import sys
import time,threading

from PyQt5 import QtGui

from un import Ui_MainWindow
import requests
from PyQt5 import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

def th():                             #清空图片
    time.sleep(2)
    ui.label_6.setPixmap(QtGui.QPixmap())

class MyThread(QThread):
    xh=pyqtSignal(float)         #信号,前端后端交互
    def __init__(self):
        super().__init__()

    def run(self):
        while True:
            re = requests.get("http://api.nlecloud.com/devices/805914/datas?apitags=wendu",{"AccessToken":"13FC4C33875167C89DD1B351C0732B011BA5D85A4B799AA439F3895CCC46411307A75CCC63E68D9C18FD73C5778264B28556CDFCF7C44B7BABBAB978E76089CA6FE0B0F398BB1D46E878532B5D3C12AE43905256B79CEB95B9054D01FC721D7910D502C53917AAD93ECC6E1D62CFAB04E3A8B8BEA7C66E0B671FB4103C48FBFB43B368DBDB7FC6C79CB637DD5009C102D1475DC754BEB7F7075A6B646EF98639E132F523B3568D904E75C479597FF8365DE080F5F9D8F65D8232701C82C864351720C2CB899FEA1D49B4F03CE8105BA257A32F4E24D3830B9F5CC0741B48939A"})
            str1=json.loads(re.text)
            s1 = str1.get("ResultObj").get("DataPoints")[0].get("PointDTO")[0].get("Value")
            print(s1)
            if float(s1)<20 :
                ui.label_4.setPixmap(QtGui.QPixmap(".png"))
                ui.label_5.setText('危险')
            elif float(s1)>30:
                ui.label_4.setPixmap(QtGui.QPixmap(".png"))
                ui.label_5.setText('告警')
            else:
                ui.label_4.setPixmap(QtGui.QPixmap("开花.png"))
                ui.label_5.setText('正常')
            self.xh.emit(s1)                        #把信号发送出去
            time.sleep(10)

    def gx(self,date):
        s1=str(date)+'%RH'
        ui.label_3.setText(s1)

    def jh(self):                  #  显示图片
            ui.label_6.setPixmap(QtGui.QPixmap("浇水.png"))
            t=threading.Thread(target=th)          #延时
            t.start()

if __name__ == '__main__':
    app=QApplication(sys.argv)
    ma=QMainWindow()
    ui =Ui_MainWindow()
    ui.setupUi(ma)
    ma.show()
    m1=MyThread()
    m1.start()
    m1.xh.connect(m1.gx)                     #连接的gx函数,调用
    ui.pushButton.clicked.connect(m1.jh)
    sys.exit(app.exec())         #退出主程序
pyuic5 -o uu.py xx.ui

pip install --no-index --find-links=file:. -r modules.txt
五、ui转py文件 pyuic5 -o out.py out.ui

六、打包 pyinstaller -Fw test.py

import json
import sys
import time,threading

from PyQt5 import QtGui

from un import Ui_MainWindow
import requests
from PyQt5 import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

def th(): #清空图片
time.sleep(2)
ui.label_6.setPixmap(QtGui.QPixmap())

class MyThread(QThread):
xh=pyqtSignal(float) #信号,前端后端交互
def init(self):
super().init()

def run(self):
while True:
re = requests.get(“http://api.nlecloud.com/devices/805914/datas?apitags=wendu”,{“AccessToken”:“13FC4C33875167C89DD1B351C0732B011BA5D85A4B799AA439F3895CCC46411307A75CCC63E68D9C18FD73C5778264B28556CDFCF7C44B7BABBAB978E76089CA6FE0B0F398BB1D46E878532B5D3C12AE43905256B79CEB95B9054D01FC721D7910D502C53917AAD93ECC6E1D62CFAB04E3A8B8BEA7C66E0B671FB4103C48FBFB43B368DBDB7FC6C79CB637DD5009C102D1475DC754BEB7F7075A6B646EF98639E132F523B3568D904E75C479597FF8365DE080F5F9D8F65D8232701C82C864351720C2CB899FEA1D49B4F03CE8105BA257A32F4E24D3830B9F5CC0741B48939A”})
str1=json.loads(re.text)
s1 = str1.get(“ResultObj”).get(“DataPoints”)[0].get(“PointDTO”)[0].get(“Value”)
print(s1)
if float(s1)<20 :
ui.label_4.setPixmap(QtGui.QPixmap(“.png”))
ui.label_5.setText(‘危险’)
elif float(s1)>30:
ui.label_4.setPixmap(QtGui.QPixmap(“.png”))
ui.label_5.setText(‘告警’)
else:
ui.label_4.setPixmap(QtGui.QPixmap(“开花.png”))
ui.label_5.setText(‘正常’)
self.xh.emit(s1) #把信号发送出去
time.sleep(10)

def gx(self,date):
s1=str(date)+‘%RH’
ui.label_3.setText(s1)

def jh(self): # 显示图片
ui.label_6.setPixmap(QtGui.QPixmap(“浇水.png”))
t=threading.Thread(target=th) #延时
t.start()

if name == ‘main’:
app=QApplication(sys.argv)
ma=QMainWindow()
ui =Ui_MainWindow()
ui.setupUi(ma)
ma.show()
m1=MyThread()
m1.start()
m1.xh.connect(m1.gx) #连接的gx函数,调用
ui.pushButton.clicked.connect(m1.jh)
sys.exit(app.exec()) #退出主程序
pyuic5 -o uu.py xx.ui

pip install --no-index --find-links=file:. -r modules.txt
五、ui转py文件 pyuic5 -o out.py out.ui

六、打包 pyinstaller -Fw test.py

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值