根据识别结果来决定识别结果的显示颜色!红色,错误,绿色,正确!

This commit is contained in:
zhanghuan
2025-09-03 11:45:48 +08:00
parent 3aabf88b1f
commit 6295ec5c1c
+10 -2
View File
@@ -676,13 +676,21 @@ class FoodClassifierApp:
)
result_title_label.pack(fill="x", padx=5, pady=(2, 0))
# 识别结果内容(大字体、红色、加粗)
# 识别结果内容(大字体、加粗,颜色根据正确性决定
is_correct = result.get('is_correct')
if is_correct is True:
result_color = "green" # 识别正确显示绿色
elif is_correct is False:
result_color = "red" # 识别错误显示红色
else:
result_color = "orange" # 无法判断显示橙色
result_content_label = ctk.CTkLabel(
info_frame,
text=result['predicted_class'],
anchor="w",
font=("Arial", 18, "bold"),
text_color="green"
text_color=result_color
)
result_content_label.pack(fill="x", padx=5, pady=(0, 2))