• 物联网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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71

    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

  • 相关阅读:
    C++ Reference: Standard C++ Library reference: C Library: cwchar: ungetwc
    网页标签在html中的显示+单标记换行操作
    打造千万级流量秒杀系统第五课 领域建模:DDD 原理及秒杀系统领域模型
    拓端tecdat|R语言时间序列分解和异常检测方法应用案例
    YOLOv5算法改进(18)— 更换激活函数(SiLU、ReLU、ELU、Hardswish、Mish、Softplus等)
    vue的使用及绑定和一些vue指令
    并联四足机器人项目开源教程(四) --- 使用QT创建控制上位机
    GO实现Redis:GO实现TCP服务器(1)
    06-Go语言中数组和切片
    深入理解JVM虚拟机_3 常见的Java虚拟机
  • 原文地址:https://blog.csdn.net/qq_28023365/article/details/133951916