小bug修改
This commit is contained in:
@@ -67,7 +67,7 @@ def create_launcher():
|
|||||||
|
|
||||||
# 说明
|
# 说明
|
||||||
info_label = tk.Label(root,
|
info_label = tk.Label(root,
|
||||||
text="提示:首次使用请先点击"配置管理"设置参数",
|
text="提示:首次使用请先点击配置管理设置参数",
|
||||||
font=('Arial', 9),
|
font=('Arial', 9),
|
||||||
fg='gray')
|
fg='gray')
|
||||||
info_label.pack(side=tk.BOTTOM, pady=10)
|
info_label.pack(side=tk.BOTTOM, pady=10)
|
||||||
|
|||||||
@@ -283,6 +283,7 @@ class PreviewWindow:
|
|||||||
photo = ImageTk.PhotoImage(image=pil_image)
|
photo = ImageTk.PhotoImage(image=pil_image)
|
||||||
# 保持引用,避免被GC
|
# 保持引用,避免被GC
|
||||||
self.photo_objects[idx] = photo
|
self.photo_objects[idx] = photo
|
||||||
|
self._grid_photos.append(photo)
|
||||||
|
|
||||||
images_to_draw.append((photo, center_x, center_y))
|
images_to_draw.append((photo, center_x, center_y))
|
||||||
texts_to_draw.append((center_x, y + 15, name, 'white'))
|
texts_to_draw.append((center_x, y + 15, name, 'white'))
|
||||||
@@ -416,6 +417,8 @@ class PreviewWindow:
|
|||||||
canvas.pack(fill=tk.BOTH, expand=True)
|
canvas.pack(fill=tk.BOTH, expand=True)
|
||||||
|
|
||||||
photo_obj = {}
|
photo_obj = {}
|
||||||
|
# 持久引用大窗当前帧 PhotoImage,避免GC
|
||||||
|
self._large_photos = []
|
||||||
|
|
||||||
def update_large_once():
|
def update_large_once():
|
||||||
if not self.running or not self.large_window.winfo_exists():
|
if not self.running or not self.large_window.winfo_exists():
|
||||||
@@ -441,8 +444,9 @@ class PreviewWindow:
|
|||||||
resized_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
resized_frame = cv2.cvtColor(resized_frame, cv2.COLOR_BGR2RGB)
|
||||||
pil_image = Image.fromarray(resized_frame)
|
pil_image = Image.fromarray(resized_frame)
|
||||||
photo = ImageTk.PhotoImage(image=pil_image)
|
photo = ImageTk.PhotoImage(image=pil_image)
|
||||||
# 保存引用到字典,确保不被GC
|
# 保存引用到字典和列表,确保不被GC
|
||||||
photo_obj['img'] = photo
|
photo_obj['img'] = photo
|
||||||
|
self._large_photos = [photo]
|
||||||
|
|
||||||
# 清空并绘制新图像
|
# 清空并绘制新图像
|
||||||
canvas.delete("all")
|
canvas.delete("all")
|
||||||
|
|||||||
Reference in New Issue
Block a user