Skip to content

Commit

Permalink
9/7 Cancel Close
Browse files Browse the repository at this point in the history
  • Loading branch information
FLwolfy committed Sep 7, 2024
1 parent a49725a commit 0bf9a7d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
16 changes: 12 additions & 4 deletions UI/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("<<Drop>>", self.drop)
self.window.bind_all("<Control-s>", self.save_config)
self.window.bind_all("<Command-s>", self.save_config)
self.window.protocol("WM_SAVE_YOURSELF", self.save_config)
Expand Down Expand Up @@ -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):
"""
Expand Down
2 changes: 0 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from UI import Panel


def main():
panel = Panel()
panel.run()


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion utils/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 0bf9a7d

Please sign in to comment.