diff --git a/waypoint_manager/scripts/manager_GUI.py b/waypoint_manager/scripts/manager_GUI.py index 2e25141..802bca5 100755 --- a/waypoint_manager/scripts/manager_GUI.py +++ b/waypoint_manager/scripts/manager_GUI.py @@ -2,6 +2,7 @@ import tkinter.filedialog import math import ruamel.yaml +import gc from pathlib import Path from tkinter import messagebox from lib.mymaplib import MyMap @@ -132,6 +133,7 @@ messagebox.showerror(title="Format error", message="Selected map file is unexpected format.") return try: + del self.mymap self.mymap = MyMap(Path(map_path), map_yaml) except FileNotFoundError: messagebox.showerror(title="Image file is not found", message="\""+map_yaml["image"]+"\" is not found.") @@ -166,6 +168,7 @@ self.menu_open_waypoints() else: self.plot_waypoints() + gc.collect() return @@ -176,12 +179,15 @@ if (self.waypoints is not None) and (self.master.title()[0] == "*"): yn = messagebox.askyesno("Confirm", "Do you want to save changes to " + str(self.waypoints_filepath)) if yn: self.save_waypoints(str(self.waypoints_filepath)) # Yes - self.canvas.delete("all") - self.draw_image() - self.plot_origin() + self.master.title(str(self.master.title()).replace("* " + self.waypoints_filepath.name + " - ", "")) + elif (self.waypoints is not None): self.master.title(str(self.master.title()).replace(self.waypoints_filepath.name + " - ", "")) - if (self.wp_info_win is not None) and (self.wp_info_win.winfo_exists()): - self.wp_info_win.destroy() + + self.canvas.delete("all") + self.draw_image() + self.plot_origin() + if (self.wp_info_win is not None) and (self.wp_info_win.winfo_exists()): + self.wp_info_win.destroy() filepath = tkinter.filedialog.askopenfilename( parent=self.master, @@ -195,6 +201,7 @@ if (not "waypoints" in wp_yaml.keys()) or (not "finish_pose" in wp_yaml.keys()): messagebox.showerror(title="Format error", message="Selected waypoints file is unexpected format.") return + del self.waypoints self.waypoints = WaypointList(wp_yaml) self.finish_pose = FinishPose(wp_yaml) self.waypoints_filepath = Path(filepath) @@ -204,6 +211,7 @@ self.file_menu.entryconfigure("Save", state=tk.NORMAL) self.file_menu.entryconfigure("Save As", state=tk.NORMAL) self.popup_menu.entryconfigure("Add waypoint here", state=tk.NORMAL) + gc.collect() return @@ -627,6 +635,7 @@ self.wp_info_win.destroy() self.disp_waypoint_info(self.editing_waypoint_id) self.update_title() + gc.collect() return add_btn = tk.Button(sub_win, text="Add", width=5, height=1, font=font, anchor=tk.CENTER, bg="#AFA") add_btn["command"] = add_param @@ -664,6 +673,7 @@ self.editing_waypoint_id = None self.moving_waypoint = False self.wp_info_win.destroy() + gc.collect() return