diff --git a/img/chato_delivering.png b/img/chato_delivering.png new file mode 100644 index 00000000..d38f1447 Binary files /dev/null and b/img/chato_delivering.png differ diff --git a/img/chato_unpackaging.png b/img/chato_unpackaging.png new file mode 100644 index 00000000..52eb66dc Binary files /dev/null and b/img/chato_unpackaging.png differ diff --git a/img/downloading_unpackaging_d.png b/img/downloading_unpackaging_d.png new file mode 100644 index 00000000..5c3c7031 Binary files /dev/null and b/img/downloading_unpackaging_d.png differ diff --git a/img/downloading_unpackaging_u.png b/img/downloading_unpackaging_u.png new file mode 100644 index 00000000..684433d5 Binary files /dev/null and b/img/downloading_unpackaging_u.png differ diff --git a/img/unpackage_icon.png b/img/unpackage_icon.png new file mode 100644 index 00000000..8fd8e7d2 Binary files /dev/null and b/img/unpackage_icon.png differ diff --git a/img/vrct_update_process.png b/img/vrct_update_process.png new file mode 100644 index 00000000..27a77150 Binary files /dev/null and b/img/vrct_update_process.png differ diff --git a/model.py b/model.py index 01e51bd7..d037cc1c 100644 --- a/model.py +++ b/model.py @@ -277,7 +277,7 @@ class Model: file.write(chunk) total_chunk += len(chunk) if isinstance(func, Callable): - func(total_chunk/file_size) + func(progress=total_chunk/file_size, progress_type="downloading") print(f"downloaded {total_chunk}/{file_size}") with ZipFile(os_path.join(tmp_path, filename)) as zf: @@ -287,7 +287,7 @@ class Model: extracted_files += 1 zf.extract(file_info, os_path.join(current_directory, tmp_directory_name)) if isinstance(func, Callable): - func(extracted_files / total_files) + func(progress=extracted_files/total_files, progress_type="extracting") print(f"extracted {extracted_files}/{total_files}") copyfile(os_path.join(current_directory, folder_name, "batch", batch_name), os_path.join(current_directory, batch_name)) diff --git a/view.py b/view.py index ce468b76..6fb59c29 100644 --- a/view.py +++ b/view.py @@ -773,6 +773,8 @@ class View(): # Insert sample conversation for testing. # self._insertSampleConversationToTextbox() + # vrct_gui.updating_window.showUpdatingWindow() + # Send Message Format def setSendMessageFormat_EntryWidgets(self, message_format:str): result = self.extractMessageFormat(message_format) @@ -1564,9 +1566,13 @@ class View(): vrct_gui.confirmation_modal.hide_buttons() vrct_gui.update() vrct_gui.confirmation_modal.update() - # vrct_gui.confirmation_modal.grab_set() #Tmp - def func(progress): - vrct_gui.confirmation_modal.updateDownloadProgress(progress=progress) + + self._hideConfirmationModal() + vrct_gui.withdraw() + vrct_gui.updating_window.showUpdatingWindow() + + def func(**kwargs): + vrct_gui.updating_window.updateDownloadProgress(**kwargs) callFunctionIfCallable(self.view_variable.CALLBACK_UPDATE_SOFTWARE, func) diff --git a/vrct_gui/updating_window/UpdatingWindow.py b/vrct_gui/updating_window/UpdatingWindow.py new file mode 100644 index 00000000..f9b90c8c --- /dev/null +++ b/vrct_gui/updating_window/UpdatingWindow.py @@ -0,0 +1,176 @@ +import math +import time + +from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame +from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation, generateGradientColor, getImagePath + +class UpdatingWindow(CTkToplevel): + def __init__(self): + super().__init__() + self.withdraw() + self.overrideredirect(True) + self.configure(fg_color="#292a2d") + self.title("Updating...") + self.after(200, lambda: self.iconbitmap(getImagePath("vrct_logo_mark_black.ico"))) + # self.wm_attributes("-toolwindow", True) + self.is_showed_downloading_process = False + self.is_showed_unpackaging_process = False + BG_WIDTH= 300 + BG_HEIGHT= 350 + self.BG_HEX_COLOR = "#292a2d" + + self.grid_columnconfigure(0, weight=1) + self.grid_rowconfigure(0, weight=1) + self.updating_background = CTkFrame(self, corner_radius=0, fg_color=self.BG_HEX_COLOR, width=BG_WIDTH, height=BG_HEIGHT) + self.updating_background.grid() + + + self.PROGRESSBAR_HEIGHT = 2 + self.PROGRESSBAR_WIDTH = 240 + self.PROGRESSBAR_Y = 240 + self.PROGRESSBAR_X = 30 + + + + + self.downloading_unpackaging_d = getImageFileFromUiUtils("downloading_unpackaging_d.png") + self.downloading_unpackaging_d_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.downloading_unpackaging_d, size=(self.downloading_unpackaging_d.width, self.downloading_unpackaging_d.height)) + ) + + + self.downloading_unpackaging_u = getImageFileFromUiUtils("downloading_unpackaging_u.png") + self.downloading_unpackaging_u_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.downloading_unpackaging_u, size=(self.downloading_unpackaging_u.width, self.downloading_unpackaging_u.height)) + ) + + + + + + + + + self.unpackage_img = getImageFileFromUiUtils("unpackage_icon.png") + + self.unpackage_img_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.unpackage_img, size=(self.unpackage_img.width, self.unpackage_img.height)) + ) + + + + + + + + self.progressbar = CTkProgressBar( + self.updating_background, + height=self.PROGRESSBAR_HEIGHT, + width=self.PROGRESSBAR_WIDTH, + corner_radius=0, + fg_color=self.BG_HEX_COLOR, + progress_color=self.BG_HEX_COLOR, + ) + self.progressbar.set(0) + self.progressbar.place(x=self.PROGRESSBAR_X, y=self.PROGRESSBAR_Y, anchor="nw") + + + self.chato_delivering_img = getImageFileFromUiUtils("chato_delivering.png") + + self.chato_delivering_img_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.chato_delivering_img, size=(self.chato_delivering_img.width, self.chato_delivering_img.height)) + ) + self.chato_delivering_img_label.place(x=-30, y=self.PROGRESSBAR_Y - 1, anchor="s") + + + + self.chato_unpackaging_img = getImageFileFromUiUtils("chato_unpackaging.png") + + self.chato_unpackaging_img_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.chato_unpackaging_img, size=(self.chato_unpackaging_img.width, self.chato_unpackaging_img.height)) + ) + self.chato_unpackaging_img_label.place(x=-30, y=self.PROGRESSBAR_Y + self.PROGRESSBAR_HEIGHT + 1, anchor="n") + + + + + + + + self.vrct_update_process_img = getImageFileFromUiUtils("vrct_update_process.png") + + self.vrct_update_process_img_label = CTkLabel( + self.updating_background, + text=None, + height=0, + fg_color=self.BG_HEX_COLOR, + image=CTkImage(self.vrct_update_process_img, size=(self.vrct_update_process_img.width, self.vrct_update_process_img.height)) + ) + self.vrct_update_process_img_label.place(x=87, y=300, anchor="nw") + + + + + + + def updateDownloadProgress(self, progress:float, progress_type:str): + if progress_type == "downloading": + if self.is_showed_downloading_process is False: + self.downloading_unpackaging_d_label.place(x=50, y=56, anchor="nw") + self.is_showed_downloading_process = True + + fg_color = generateGradientColor( + value=progress, + color_start=[242, 242, 242], # RGB values for #f2f2f2 + color_end=[72, 164, 149], # RGB values for #48a495 + ) + self.progressbar.configure(fg_color=fg_color) + + chato_x = self.PROGRESSBAR_X + (progress * self.PROGRESSBAR_WIDTH) + self.chato_delivering_img_label.place(x=chato_x) + self.progressbar.set(progress) + self.update_idletasks() + + elif progress_type == "extracting": + if self.is_showed_unpackaging_process is False: + self.chato_delivering_img_label.place_forget() + self.downloading_unpackaging_u_label.place(x=50, y=56, anchor="nw") + self.unpackage_img_label.place(x=130, y=174, anchor="nw") + self.progressbar.configure(fg_color=self.BG_HEX_COLOR, progress_color="#4B4C4F") + self.is_showed_unpackaging_process = True + + chato_x = (self.PROGRESSBAR_X - 3) + (self.PROGRESSBAR_WIDTH - (progress * self.PROGRESSBAR_WIDTH)) + self.chato_unpackaging_img_label.place(x=chato_x) + self.progressbar.set(1 - progress) + self.update_idletasks() + + + def showUpdatingWindow(self): + self.attributes("-alpha", 0) + self.deiconify() + setGeometryToCenterOfScreen(root_widget=self) + fadeInAnimation(self, steps=5, interval=0.02) + + + def destroyUpdatingWindow(self): + self.destroy() \ No newline at end of file diff --git a/vrct_gui/updating_window/__init__.py b/vrct_gui/updating_window/__init__.py new file mode 100644 index 00000000..feed896e --- /dev/null +++ b/vrct_gui/updating_window/__init__.py @@ -0,0 +1 @@ +from .UpdatingWindow import UpdatingWindow \ No newline at end of file diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index 0a795436..6f9183b9 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -2,6 +2,8 @@ from customtkinter import CTk, CTkImage from ._CreateSelectableLanguagesWindow import _CreateSelectableLanguagesWindow +from .updating_window import UpdatingWindow + from ._CreateWindowCover import _CreateWindowCover from ._CreateNotificationWindow import _CreateNotificationWindow from ._CreateDropdownMenuWindow import _CreateDropdownMenuWindow @@ -173,6 +175,8 @@ class VRCT_GUI(CTk): init_scaling=(self._view_variable.VAR_TEXTBOX_UI_SCALING.get()/100) ) + self.updating_window = UpdatingWindow() +