From 9dcef19a4b7caf46d13d9698d95b9216616bb15d Mon Sep 17 00:00:00 2001 From: Egezenn Date: Sat, 22 Feb 2025 17:20:31 +0300 Subject: [PATCH] Fixes & improvements - Fixes a warning regarding odg if the default guides were already backed up (files not being able to move, expected behavior) - Bound escape to destroy the info windows --- gui.pyw | 25 ++++++++++++++++--------- helper.py | 1 + 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/gui.pyw b/gui.pyw index 3af8991..646004f 100644 --- a/gui.pyw +++ b/gui.pyw @@ -455,15 +455,20 @@ class App: exist_ok=True, ) for name in os.listdir(mpaths.itembuilds_dir): - if name != "bkup": - os.rename( - os.path.join( - mpaths.itembuilds_dir, name - ), - os.path.join( - mpaths.itembuilds_dir, "bkup", name - ), - ) + try: + if name != "bkup": + os.rename( + os.path.join( + mpaths.itembuilds_dir, name + ), + os.path.join( + mpaths.itembuilds_dir, + "bkup", + name, + ), + ) + except FileExistsError: + pass # backup was created and opendotaguides was replacing the guides already shutil.unpack_archive( zip_path, temp_dump_path, "zip" ) @@ -477,6 +482,8 @@ class App: print( "→ Replaced default guides with OpenDotaGuides guides." ) + if os.path.exists(zip_path): + os.remove(zip_path) else: print( "→ Failed to download latest OpenDotaGuides guides." diff --git a/helper.py b/helper.py index d63b7d0..633d575 100644 --- a/helper.py +++ b/helper.py @@ -87,6 +87,7 @@ def modInfo(widget, name, mod_path, event): height=1, width=10, ) + infoWindow.bind("", lambda e: infoWindow.destroy()) close_button.grid(row=1, column=0, pady=5)