From 286b81c678b764d4595a67037f2cd83a7db2f7ac Mon Sep 17 00:00:00 2001 From: 123 <2070873540@qq.com> Date: Thu, 30 May 2024 16:38:19 +0800 Subject: [PATCH] fourth commit --- 智能家居系统/5.py | 60 +++++++++++ .../__pycache__/主页面.cpython-311.pyc | Bin 2872 -> 2970 bytes .../__pycache__/家居信息.cpython-311.pyc | Bin 20085 -> 20085 bytes 智能家居系统/主页面.py | 11 +- 智能家居系统/安全警报.py | 37 ------- 智能家居系统/环境监测.py | 95 ++++++++++++++++++ 智能家居系统/登录界面.py | 3 +- 7 files changed, 163 insertions(+), 43 deletions(-) create mode 100644 智能家居系统/5.py delete mode 100644 智能家居系统/安全警报.py create mode 100644 智能家居系统/环境监测.py diff --git a/智能家居系统/5.py b/智能家居系统/5.py new file mode 100644 index 0000000..9915c70 --- /dev/null +++ b/智能家居系统/5.py @@ -0,0 +1,60 @@ +import tkinter as tk +from tkinter import ttk +import random +import time + + +class EnvironmentMonitorApp: + def __init__(self, root): + self.root = root + self.root.title("环境监测数据展示") + + # 初始化数据 + self.temperature = 0 + self.humidity = 0 + self.light_intensity = 0 + self.record_count = 0 # 新增记录计数器 + + # 创建表格 + self.treeview = ttk.Treeview(root, columns=("序号", "参数", "值"), show="headings") + self.treeview.column("序号", width=50, anchor=tk.CENTER) + self.treeview.column("参数", width=100, anchor=tk.CENTER) + self.treeview.column("值", width=100, anchor=tk.CENTER) + self.treeview.heading("序号", text="序号") + self.treeview.heading("参数", text="参数") + self.treeview.heading("值", text="值") + self.treeview.pack(padx=10, pady=10) + + # 模拟数据更新 + self.root.after(5000, self.update_data_and_display) # 每5秒更新一次数据 + + def simulate_data(self): + """Simulate environment data.""" + self.temperature = random.uniform(20, 30) # 温度范围20°C至30°C + self.humidity = random.uniform(30, 70) # 湿度范围30%至70% + self.light_intensity = random.randint(100, 1000) # 光照强度100至1000勒克斯 + self.record_count += 1 # 记录数加一 + + def update_table(self): + """Append new data to the table.""" + # 插入新数据,记录计数作为第一列 + self.treeview.insert("", tk.END, values=(self.record_count, "温度", f"{self.temperature:.2f} °C")) + self.treeview.insert("", tk.END, values=(self.record_count, "湿度", f"{self.humidity:.2f}%")) + self.treeview.insert("", tk.END, values=(self.record_count, "光照强度", f"{self.light_intensity} lux")) + + def update_data_and_display(self): + """Update data and append to table display.""" + self.simulate_data() + self.update_table() + # 递归调用以持续更新 + self.root.after(5000, self.update_data_and_display) + + +def main(): + root = tk.Tk() + app = EnvironmentMonitorApp(root) + root.mainloop() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/智能家居系统/__pycache__/主页面.cpython-311.pyc b/智能家居系统/__pycache__/主页面.cpython-311.pyc index 35622b913d886534a136aa36a9aafb1759930b72..3034c64eb9bdfc23d7f2094109005903bbee04e5 100644 GIT binary patch delta 240 zcmdlXHcOm$IWI340}xDCib(rAkyn!O!$kEIM%RfwaxAHw3%Djba){`pa4utHU|0>r z5WvX5#E{CGiY6Mx4b;E`)S$wZ!Whf|!kSzgKTTrh;sk1Y+BN@0^WMo5S>Ez;U+{{) zARlv4KIV#i%;s*^EEeTb8K9D9Gj{=%JYBc#>BiRQn|D9oJzw|9j@>U8Zhbj-ktXlt z@0?C-tRyJlV1P<-)Bm=PsJOgXJwR-v!^e3-a+7<>Rl& z$8X-mn#IDT$urrW%V}~4mj;(9P(8@p;-iyyaV?%)z%9qa&cGsdfmyOh3@8i$_W&wL diff --git a/智能家居系统/__pycache__/家居信息.cpython-311.pyc b/智能家居系统/__pycache__/家居信息.cpython-311.pyc index f5a6f70fba065786f92f05dabfb9b9925084b3a9..d006a5b19f4158dab234f1ec08ab333bac6acfd1 100644 GIT binary patch delta 22 ccmex5hw