Merge pull request #19 from faroukbmiled/refactored

Fixes
This commit is contained in:
Ryuk 2023-09-29 12:24:25 -07:00 committed by GitHub
commit 8adaa9fa1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -354,7 +354,7 @@ def get_item_name(id):
def show_noti(widget ,message, event=None, noti_dur=3.0, topmost=False): def show_noti(widget ,message, event=None, noti_dur=3.0, topmost=False):
CTkToolTip(widget, message=message, is_noti=True, noti_event=event, noti_dur=noti_dur, topmost=topmost) CTkToolTip(widget, message=message, is_noti=True, noti_event=event, noti_dur=noti_dur, topmost=topmost)
def check_item_date(down_date, date_updated): def check_item_date(down_date, date_updated, format=False):
current_year = datetime.now().year current_year = datetime.now().year
date_format_with_year = "%d %b, %Y @ %I:%M%p" date_format_with_year = "%d %b, %Y @ %I:%M%p"
date_format_with_added_year = "%d %b @ %I:%M%p, %Y" date_format_with_added_year = "%d %b @ %I:%M%p, %Y"
@ -364,6 +364,12 @@ def check_item_date(down_date, date_updated):
except ValueError: except ValueError:
download_datetime = datetime.strptime(down_date + f", {current_year}", date_format_with_added_year) download_datetime = datetime.strptime(down_date + f", {current_year}", date_format_with_added_year)
if format:
try:
date_updated = datetime.strptime(date_updated, date_format_with_year)
except ValueError:
date_updated = datetime.strptime(date_updated + f", {current_year}", date_format_with_added_year)
if date_updated >= download_datetime: if date_updated >= download_datetime:
return True return True
elif date_updated < download_datetime: elif date_updated < download_datetime:

View File

@ -675,7 +675,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
def check_for_updates(): def check_for_updates():
try: try:
if check_item_date(down_date, date_updated): if check_item_date(down_date, date_updated, format=True):
if show_message("There is an update.", "Press download to redownload!", icon="info", _return=True, option_1="No", option_2="Download"): if show_message("There is an update.", "Press download to redownload!", icon="info", _return=True, option_1="No", option_2="Download"):
if main_app.app.is_downloading: if main_app.app.is_downloading:
show_message("Error", "Please wait for the current download to finish or stop it then restart.", icon="cancel") show_message("Error", "Please wait for the current download to finish or stop it then restart.", icon="cancel")
@ -909,7 +909,7 @@ class LibraryTab(ctk.CTkScrollableFrame):
_, _, x, y = get_window_size_from_registry() _, _, x, y = get_window_size_from_registry()
top.geometry(f"{window_width}x{window_height}+{x}+{y}") top.geometry(f"{window_width}x{window_height}+{x}+{y}")
top.maxsize(window_width + 100, 450) top.maxsize(window_width + 100, 450)
top.attributes('-topmost', 'true') top.minsize(window_width - 5, window_height-100)
top.resizable(True, True) top.resizable(True, True)
selected_id_list = [] selected_id_list = []
cevent = Event() cevent = Event()
@ -1006,5 +1006,6 @@ class LibraryTab(ctk.CTkScrollableFrame):
show_message("Error", f"{e}", icon="cancel") show_message("Error", f"{e}", icon="cancel")
finally: finally:
main_app.app.after(150, lambda: top.focus_force())
self.update_button.configure(state="normal", width=65, height=20) self.update_button.configure(state="normal", width=65, height=20)
self.update_tooltip.configure(message='Check items for updates') self.update_tooltip.configure(message='Check items for updates')

View File

@ -721,7 +721,7 @@ class SettingsTab(ctk.CTkFrame):
main_app.app.create_context_menu(boiii_folder_entry) main_app.app.create_context_menu(boiii_folder_entry)
copy_var.set(True) copy_var.set(True)
progress_bar.set(0) progress_bar.set(0)
top.after(120, top.focus_force) top.after(150, top.focus_force)
except Exception as e: except Exception as e:
show_message("Error", f"{e}", icon="cancel") show_message("Error", f"{e}", icon="cancel")