修复了预览窗口显示层级的问题,标题增加“数字味道”!
This commit is contained in:
@@ -77,7 +77,7 @@ class FoodCNN(nn.Module):
|
|||||||
class FoodClassifierApp:
|
class FoodClassifierApp:
|
||||||
def __init__(self, root):
|
def __init__(self, root):
|
||||||
self.root = root
|
self.root = root
|
||||||
self.root.title("食物识别系统")
|
self.root.title("数字味道-食物识别系统")
|
||||||
self.root.geometry("1400x800")
|
self.root.geometry("1400x800")
|
||||||
|
|
||||||
# 食物类别(根据您的数据集)
|
# 食物类别(根据您的数据集)
|
||||||
@@ -480,6 +480,18 @@ class FoodClassifierApp:
|
|||||||
preview_window.title(f"预览 - {img_info['name']}")
|
preview_window.title(f"预览 - {img_info['name']}")
|
||||||
preview_window.geometry("800x600")
|
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 = self.resize_image_for_display(img_info['image'], 750, 550)
|
||||||
display_image = cv2.cvtColor(display_image, cv2.COLOR_BGR2RGB)
|
display_image = cv2.cvtColor(display_image, cv2.COLOR_BGR2RGB)
|
||||||
|
|||||||
Reference in New Issue
Block a user