diff --git a/view.py b/view.py index a7466fa8..ce468b76 100644 --- a/view.py +++ b/view.py @@ -1564,7 +1564,10 @@ class View(): vrct_gui.confirmation_modal.hide_buttons() vrct_gui.update() vrct_gui.confirmation_modal.update() - callFunctionIfCallable(self.view_variable.CALLBACK_UPDATE_SOFTWARE) + # vrct_gui.confirmation_modal.grab_set() #Tmp + def func(progress): + vrct_gui.confirmation_modal.updateDownloadProgress(progress=progress) + callFunctionIfCallable(self.view_variable.CALLBACK_UPDATE_SOFTWARE, func) diff --git a/vrct_gui/_CreateConfirmationModal.py b/vrct_gui/_CreateConfirmationModal.py index 7391a594..898e9c84 100644 --- a/vrct_gui/_CreateConfirmationModal.py +++ b/vrct_gui/_CreateConfirmationModal.py @@ -1,6 +1,6 @@ -from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont +from customtkinter import CTkToplevel, CTkFrame, CTkLabel, CTkFont, CTkProgressBar -from .ui_utils import fadeInAnimation, setGeometryToCenterOfTheWidget, bindButtonFunctionAndColor +from .ui_utils import fadeInAnimation, setGeometryToCenterOfTheWidget, bindButtonFunctionAndColor, generateGradientColor from utils import callFunctionIfCallable @@ -13,6 +13,7 @@ class _CreateConfirmationModal(CTkToplevel): self.settings = settings self._view_variable = view_variable + self.is_showed_progressbar = False self.title("") self.overrideredirect(True) @@ -69,6 +70,18 @@ class _CreateConfirmationModal(CTkToplevel): self.modal_buttons_wrapper.grid(row=1, column=0, sticky="ew") + # Progress bar + self.progressbar_widget = CTkProgressBar( + self.modal_contents_wrapper, + height=8, + corner_radius=0, + fg_color="black", + # fg_color="#4b4c4f", + progress_color="gray", + ) + self.progressbar_widget.set(0) + + if modal_type == "information": self.modal_buttons_wrapper.grid_columnconfigure((0,2), weight=1) @@ -237,5 +250,21 @@ class _CreateConfirmationModal(CTkToplevel): return callFunctionIfCallable(self._view_variable.CALLBACK_HIDE_CONFIRMATION_MODAL) + + def updateDownloadProgress(self, progress:float): + if self.is_showed_progressbar is False: + self.progressbar_widget.place(relwidth=0.9, relx=0.5, rely=0.84, anchor="s") + self.is_showed_progressbar = True + self.update() + + progress_color = generateGradientColor( + value=progress, + color_start=[242, 242, 242], # RGB values for #f2f2f2 + color_end=[72, 164, 149], # RGB values for #48a495 + ) + self.progressbar_widget.configure(progress_color=progress_color) + self.progressbar_widget.set(progress) + self.update_idletasks() + def _grab_set(self): self.grab_set() diff --git a/vrct_gui/splash_window/SplashWindow.py b/vrct_gui/splash_window/SplashWindow.py index 3a1084c0..a0b5ad31 100644 --- a/vrct_gui/splash_window/SplashWindow.py +++ b/vrct_gui/splash_window/SplashWindow.py @@ -2,7 +2,7 @@ import math import time from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar, CTkFrame -from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation +from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation, generateGradientColor class SplashWindow(CTkToplevel): def __init__(self): @@ -200,25 +200,6 @@ class SplashWindow(CTkToplevel): rotated_image = image.rotate(angle, expand=True) return rotated_image - # This making gradient color process was made by ChatGPT. - def generateGradientColor(self, value): - # 0の時の色と1の時の色を指定 - color_start = [242, 242, 242] # RGB values for #f2f2f2 - color_end = [72, 164, 149] # RGB values for #48a495 - - # 補完色を計算 - interpolated_color = [ - int(start + (end - start) * value) for start, end in zip(color_start, color_end) - ] - - # RGB値を0から255の範囲にクリップ - interpolated_color = [max(0, min(255, val)) for val in interpolated_color] - - # RGBを16進数に変換 - hex_color = "#{:02x}{:02x}{:02x}".format(*interpolated_color) - - return hex_color - def updateDownloadProgress(self, progress:float): if self.is_showed_weight_download_progressbar is False: @@ -232,7 +213,11 @@ class SplashWindow(CTkToplevel): self.is_showed_weight_download_progressbar = True self.update() - progress_color = self.generateGradientColor(progress) + progress_color = generateGradientColor( + value=progress, + color_start=[242, 242, 242], # RGB values for #f2f2f2 + color_end=[72, 164, 149], # RGB values for #48a495 + ) self.weight_download_progressbar_widget.configure(progress_color=progress_color) self.weight_download_progressbar_widget.set(progress) self.update_idletasks() diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index fc4b35e7..7af40855 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -71,6 +71,22 @@ def calculateUiSize(default_size, scaling_float, is_allowed_odd:bool=False, is_z return size +# This making gradient color process was made by ChatGPT. +def generateGradientColor(value, color_start, color_end): + # 補完色を計算 + interpolated_color = [ + int(start + (end - start) * value) for start, end in zip(color_start, color_end) + ] + + # RGB値を0から255の範囲にクリップ + interpolated_color = [max(0, min(255, val)) for val in interpolated_color] + + # RGBを16進数に変換 + hex_color = "#{:02x}{:02x}{:02x}".format(*interpolated_color) + + return hex_color + + def bindEnterAndLeaveColor(target_widgets, enter_color, leave_color): for target_widget in target_widgets: target_widget.bind("", lambda e, widgets=target_widgets: [w.configure(fg_color=enter_color) for w in widgets], "+")