增加了状态显示弹窗
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
import socket
|
||||
import struct
|
||||
import tkinter as tk
|
||||
import threading
|
||||
from udpmsg import *
|
||||
from datetime import datetime
|
||||
from tkinter import font
|
||||
from guiEle import ElementDisplayApp
|
||||
from until import *
|
||||
from guiInput import InputGUI
|
||||
|
||||
# 创建UDP套接字
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
server_address = ('localhost', 5001)
|
||||
sock.bind(server_address)
|
||||
|
||||
# 创建主窗口
|
||||
root = tk.Tk()
|
||||
root.title("UDP消息显示")
|
||||
eleplay = ElementDisplayApp(root)
|
||||
inp = InputGUI(root)
|
||||
|
||||
# 创建一个文本框用于显示消息
|
||||
custom_font = font.Font(family="Arial", size=12, weight="normal")
|
||||
text_box = tk.Text(root, height=10, width=50, font=custom_font)
|
||||
# .pack(side='left', fill='y', expand=True)
|
||||
text_box.grid(row=0, column=4, sticky='ne')
|
||||
|
||||
# 创建并启动接收和发送消息的线程
|
||||
thread = threading.Thread(target=receive_messages, args=(sock, text_box,eleplay))
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
thread2 = threading.Thread(target=send_messages, args=(sock, eleplay))
|
||||
thread2.daemon = True
|
||||
thread2.start()
|
||||
|
||||
# 运行主循环
|
||||
root.mainloop()
|
||||
|
||||
# 关闭套接字
|
||||
sock.close()
|
||||
Reference in New Issue
Block a user