判断表名是否为“產綫-Router机粉塵記錄表”,如果是,则清空文本框 if sheet_name == "產綫-Router机粉塵記錄表": self.textbox.delete(1.0, tk.END) # 添加表名并设置居中标签 self.textbox.insert(tk.END, sheet_name + ":\n", "center") # 获取当前时间是在哪一组中 time_groups = ["08:00-10:00", "10:00-12:00", "12:00-14:00", "14:00-16:00", "16:00-18:00", "18:00-20:00", "20:00-22:00", "22:00-00:00", "00:00-02:00", "02:00-04:00", "04:00-06:00", "06:00-08:00"] now_time = datetime.datetime.now().strftime('%H:%M') for i in range(len(time_groups)): if now_time >= time_groups[i].split("-")[0] and now_time < time_groups[i].split("-")[1]: current_time_group = time_groups[i] break # 将当前时间段添加到文本框中 self.textbox.insert(tk.END, current_time_group + ":\n", "left") # 将当前时间段和下拉输入框添加到文本框中 combobox = tk.ttk.Combobox(self.textbox, values=["OK", "NG", "未開綫", "未使用"]) combobox.pack(side=tk.TOP, padx=10, pady=5) self.textbox.window_create(tk.END, window=combobox)將這段代碼中下拉輸入框修改到文本框内獲取的時間段前
时间: 2023-09-09 10:07:04 浏览: 86
MySQL Router 8.0.27(mysql-router-community-8.0.27-1.el7.x86_64)
将下拉输入框的代码修改到获取当前时间段的代码前,代码如下:
# 判断表名是否为“產綫-Router机粉塵記錄表”,如果是,则清空文本框
if sheet_name == "產綫-Router机粉塵記錄表":
self.textbox.delete(1.0, tk.END)
# 添加表名并设置居中标签
self.textbox.insert(tk.END, sheet_name + ":\n", "center")
# 获取当前时间是在哪一组中
time_groups = ["08:00-10:00", "10:00-12:00", "12:00-14:00", "14:00-16:00", "16:00-18:00", "18:00-20:00", "20:00-22:00", "22:00-00:00", "00:00-02:00", "02:00-04:00", "04:00-06:00", "06:00-08:00"]
now_time = datetime.datetime.now().strftime('%H:%M')
for i in range(len(time_groups)):
if now_time >= time_groups[i].split("-")[0] and now_time < time_groups[i].split("-")[1]:
current_time_group = time_groups[i]
break
# 将当前时间段和下拉输入框添加到文本框中
combobox = tk.ttk.Combobox(self.textbox, values=["OK", "NG", "未開綫", "未使用"])
self.textbox.window_create(tk.END, window=combobox)
self.textbox.insert(tk.END, current_time_group + ":\n", "left")
阅读全文