diff --git a/UI/panel.py b/UI/panel.py index 584fdff..43123dd 100644 --- a/UI/panel.py +++ b/UI/panel.py @@ -21,6 +21,7 @@ def __init__(self, width:int=1000, height:int=720): self.window.columnconfigure(1, weight=1) # Window Events + # self.window.bind_all("<>", self.drop) self.window.bind_all("", self.save_config) self.window.bind_all("", self.save_config) self.window.protocol("WM_SAVE_YOURSELF", self.save_config) @@ -695,17 +696,24 @@ def set_config(self, name:str, obj: any, is_widget = True): else: self.widgets["save"].config(text="💾 !", fg="red") - + def close(self): """ Handle the closing event of the window. """ if not self.task.is_saved(): - if not messagebox.askyesno("Save", "Do you want to save the current configuration?"): - self.window.destroy() + result = messagebox.askyesnocancel("Save", "Do you want to save the current configuration?") + if result is None: # Cancel return - self.save_config() + elif result: # Yes + self.save_config() self.window.destroy() + + def drop(self): + """ + Drop the file of the panel. + """ + print("DROP!") def run(self): """ diff --git a/main.py b/main.py index eefa3e1..e29b070 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,8 @@ from UI import Panel - def main(): panel = Panel() panel.run() - if __name__ == "__main__": main() diff --git a/utils/project.py b/utils/project.py index 23cb229..1f8359a 100644 --- a/utils/project.py +++ b/utils/project.py @@ -76,9 +76,9 @@ def write_config(self): if not self.__is_saved: self.__original_state = copy.deepcopy(json_obj) + self.__is_saved = True path = os.path.realpath(self.__config_path) - self.__is_saved = True IO.write_json(json_obj, path) def is_saved(self):