From 573694b287235a349fa79eabeedef45492b7c337 Mon Sep 17 00:00:00 2001 From: jakeallen Date: Wed, 27 Mar 2024 00:43:01 +0800 Subject: [PATCH] new_test --- send.py | 84 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 43 deletions(-) diff --git a/send.py b/send.py index 0b67215..e0f3b76 100644 --- a/send.py +++ b/send.py @@ -21,64 +21,62 @@ class SendApp: self.send_label = tk.Label(self.send_data_frame, text="发送数据") self.send_label.pack(side=tk.LEFT) - self.send_entry = tk.Entry(self.send_data_frame, width=90) + self.send_entry = tk.Entry(self.send_data_frame, width=50) self.send_entry.pack(side=tk.LEFT) + # 创建元数据子框架 + self.metadata_frame = tk.LabelFrame(self.send_frame, text='元数据', padx=10, pady=10) + self.metadata_frame.pack(side=tk.TOP, fill=tk.X, expand=True) + # 输入帧头 - self.first_message_label = tk.Label(self.send_frame, text="帧头:") - self.first_message_label.pack(side=tk.LEFT) - self.first_message_entry = tk.Entry(self.send_frame) - self.first_message_entry.pack(side=tk.LEFT) + self.first_message_label = tk.Label(self.metadata_frame, text="帧头:") + self.first_message_label.grid(row=0, column=0) + self.first_message_entry = tk.Entry(self.metadata_frame) + self.first_message_entry.grid(row=0, column=1) # 流水号 - self.flow_msg_label = tk.Label(self.send_frame, text="流水号:") - self.flow_msg_label.pack(side=tk.LEFT) - self.flow_msg_entry = tk.Entry(self.send_frame) - self.flow_msg_entry.pack(side=tk.LEFT) + self.flow_msg_label = tk.Label(self.metadata_frame, text="流水号:") + self.flow_msg_label.grid(row=0, column=2) + self.flow_msg_entry = tk.Entry(self.metadata_frame) + self.flow_msg_entry.grid(row=0, column=3) # 时标 - self.time_msg_label = tk.Label(self.send_frame, text="时标:") - self.time_msg_label.pack(side=tk.LEFT) - self.time_msg_entry = tk.Entry(self.send_frame) - self.time_msg_entry.pack(side=tk.LEFT) + self.time_msg_label = tk.Label(self.metadata_frame, text="时标:") + self.time_msg_label.grid(row=0, column=4) + self.time_msg_entry = tk.Entry(self.metadata_frame) + self.time_msg_entry.grid(row=0, column=5) + + # 输入帧尾 + self.last_message_label = tk.Label(self.metadata_frame, text="帧尾:") + self.last_message_label.grid(row=1, column=0) + self.last_message_entry = tk.Entry(self.metadata_frame) + self.last_message_entry.grid(row=1, column=1) - # 时标(秒内计数器) - self.sec_time_msg_label = tk.Label(self.send_frame, text="时标(秒内计数器):") - self.sec_time_msg_label.pack(side=tk.LEFT) - self.sec_time_msg_entry = tk.Entry(self.send_frame) - self.sec_time_msg_entry.pack(side=tk.LEFT) + # 报文类型 & 数据长度 & 数据段 + self.payload_frame = tk.LabelFrame(self.send_frame, text='有效负载', padx=10, pady=10) + self.payload_frame.pack(side=tk.TOP, fill=tk.X, expand=True) # 报文类型 - self.type_msg_label = tk.Label(self.send_frame, text="报文类型:") - self.type_msg_label.pack(side=tk.LEFT) - self.type_msg_entry = tk.Entry(self.send_frame) - self.type_msg_entry.pack(side=tk.LEFT) + self.type_msg_label = tk.Label(self.payload_frame, text="报文类型:") + self.type_msg_label.grid(row=0, column=0) + self.type_msg_entry = tk.Entry(self.payload_frame) + self.type_msg_entry.grid(row=0, column=1) # 数据长度 - self.length_msg_label = tk.Label(self.send_frame, text="数据长度:") - self.length_msg_label.pack(side=tk.LEFT) - self.length_msg_entry = tk.Entry(self.send_frame) - self.length_msg_entry.pack(side=tk.LEFT) + self.length_msg_label = tk.Label(self.payload_frame, text="数据长度:") + self.length_msg_label.grid(row=0, column=2) + self.length_msg_entry = tk.Entry(self.payload_frame) + self.length_msg_entry.grid(row=0, column=3) # 数据段 - self.data_msg_label = tk.Label(self.send_frame, text="数据段:") - self.data_msg_label.pack(side=tk.LEFT) - self.data_msg_entry = tk.Entry(self.send_frame) - self.data_msg_entry.pack(side=tk.LEFT) - - # 输入帧尾 - self.last_message_label = tk.Label(self.send_frame, text="帧尾:") - self.last_message_label.pack(side=tk.LEFT) - self.last_message_entry = tk.Entry(self.send_frame) - self.last_message_entry.pack(side=tk.LEFT) - - # 创建一个包含发送按钮的框架 - self.send_button_frame = tk.Frame(self.send_frame) - self.send_button_frame.pack(fill=tk.X, padx=10, pady=10) # 框架会填充整个水平方向 + self.data_msg_label = tk.Label(self.payload_frame, text="数据段:") + self.data_msg_label.grid(row=1, column=0) + self.data_msg_entry = tk.Entry(self.payload_frame) + self.data_msg_entry.grid(row=1, column=1) - # 将发送按钮放入这个新的框架,并让它在框架中居中 - self.send_button = tk.Button(self.send_button_frame, text="发送", command=self.send_message) - self.send_button.pack(side=tk.TOP, pady=10) # 这里不需要使用 anchor 参数,因为框架是填充整个水平方向的 + # 创建发送按钮 + self.send_button = tk.Button(self.send_frame, text="发送", command=self.send_message) + self.send_button.pack(side=tk.LEFT, pady=10) # 接收区域 self.recv_frame = tk.Frame(window)