From 068c6977c932cec232a5bd8dd35ebe8fe200a98f Mon Sep 17 00:00:00 2001 From: zhanghuan <1262329256@qq.com> Date: Wed, 3 Sep 2025 12:04:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=98=BE=E7=A4=BA=E5=B1=82=E7=BA=A7=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=8C=E6=A0=87=E9=A2=98=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E2=80=9C=E6=95=B0=E5=AD=97=E5=91=B3=E9=81=93=E2=80=9D=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classifier/food_classifier_app.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/classifier/food_classifier_app.py b/classifier/food_classifier_app.py index bb6966d..ba37b87 100644 --- a/classifier/food_classifier_app.py +++ b/classifier/food_classifier_app.py @@ -77,7 +77,7 @@ class FoodCNN(nn.Module): class FoodClassifierApp: def __init__(self, root): self.root = root - self.root.title("食物识别系统") + self.root.title("数字味道-食物识别系统") self.root.geometry("1400x800") # 食物类别(根据您的数据集) @@ -480,6 +480,18 @@ class FoodClassifierApp: preview_window.title(f"预览 - {img_info['name']}") preview_window.geometry("800x600") + # 设置窗口属性,确保在主窗口上方 + preview_window.transient(self.root) # 设置为主窗口的子窗口 + preview_window.grab_set() # 设置为模态窗口 + preview_window.lift() # 提升到最前面 + preview_window.focus_set() # 设置焦点 + + # 居中显示 + preview_window.update_idletasks() + x = (preview_window.winfo_screenwidth() // 2) - (800 // 2) + y = (preview_window.winfo_screenheight() // 2) - (600 // 2) + preview_window.geometry(f"800x600+{x}+{y}") + # 显示图片 display_image = self.resize_image_for_display(img_info['image'], 750, 550) display_image = cv2.cvtColor(display_image, cv2.COLOR_BGR2RGB)