增加了状态显示弹窗
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import socket
|
||||
import struct
|
||||
import tkinter as tk
|
||||
import threading
|
||||
from udpmsg import *
|
||||
from datetime import datetime
|
||||
from disSys import *
|
||||
from logWin import *
|
||||
from udpComm import *
|
||||
|
||||
|
||||
# 创建UDP通信套接字
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
# 目标IP地址和端口号
|
||||
target_ip = 'localhost'
|
||||
target_port = 5001
|
||||
server_address = (target_ip, target_port)
|
||||
sock.bind(server_address)
|
||||
# 要发送的消息
|
||||
# 创建主窗口
|
||||
root = tk.Tk()
|
||||
root.title("能源管理系统调试")
|
||||
# 创建消息显示窗口
|
||||
logFrame = tk.LabelFrame(root, text="消息显示")
|
||||
logFrame.grid(row=1, columnspan=3 ,column=0, sticky='nsw')
|
||||
logwin = logWin(logFrame)
|
||||
logwin.grid(row=0, column=0, sticky='nesw')
|
||||
# 创建配电窗口
|
||||
disSysFrame = tk.LabelFrame(root, text="配电系统")
|
||||
disSysFrame.grid(row=0, column=0, sticky='ne')
|
||||
disSysWin = disSys(disSysFrame)
|
||||
disSysWin.grid(row=0, column=0, sticky='ne')
|
||||
|
||||
# 创建并启动接收和发送消息的线程
|
||||
thread = threading.Thread(target=receive_messages, args=(sock, logwin, disSysWin))
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
thread2 = threading.Thread(target=send_messages, args=(sock, logwin, disSysWin))
|
||||
thread2.daemon = True
|
||||
thread2.start()
|
||||
|
||||
|
||||
# 运行主循环
|
||||
root.mainloop()
|
||||
# 关闭套接字
|
||||
sock.close()
|
||||
Reference in New Issue
Block a user