From fe1c0a45d71c8bdb9c33a2e2a1d4485348e068cb Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Sun, 14 Apr 2024 07:35:34 +0900 Subject: [PATCH] =?UTF-8?q?[WIP/TEST]=20=E3=82=A2=E3=83=97=E3=83=87?= =?UTF-8?q?=E6=99=82=E3=81=AB=E3=83=97=E3=83=AD=E3=82=B0=E3=83=AC=E3=82=B9?= =?UTF-8?q?=E3=83=90=E3=83=BC=E3=82=92=E8=A1=A8=E7=A4=BA=E3=80=82=E2=80=BB?= =?UTF-8?q?WIP=20=E6=B3=A8=E6=84=8F=E4=BA=8B=E9=A0=85=E3=81=82=E3=82=8A=20?= =?UTF-8?q?=E3=83=BB=E4=BB=96=E3=81=AE=E3=82=A6=E3=82=A3=E3=83=B3=E3=83=89?= =?UTF-8?q?=E3=82=A6=E3=81=AB=E3=83=95=E3=82=A9=E3=83=BC=E3=82=AB=E3=82=B9?= =?UTF-8?q?=E3=82=92=E5=BD=93=E3=81=A6=E3=82=8B=E3=81=A8=E6=B6=88=E3=81=88?= =?UTF-8?q?=E3=81=BE=E3=81=99=E3=80=82=EF=BC=88=E5=BE=8C=E3=82=8D=E3=81=A7?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=81=AF=E5=8B=95=E3=81=84=E3=81=A6=E3=81=84?= =?UTF-8?q?=E3=82=8B=EF=BC=89=20=E3=83=BB=E3=83=80=E3=83=BC=E3=82=AF?= =?UTF-8?q?=E3=83=A2=E3=83=BC=E3=83=89=E3=81=AE=E3=81=BF=E3=81=AE=E5=AF=BE?= =?UTF-8?q?=E5=BF=9C=E3=81=A7=E3=81=99=E3=80=82=20=E3=83=BB=E3=81=A8?= =?UTF-8?q?=E3=82=8A=E3=81=82=E3=81=88=E3=81=9A=E3=81=AE=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E3=81=A7=E3=81=99=E3=80=82downloaded=E3=81=A8extracted?= =?UTF-8?q?=E3=81=A72=E5=9B=9E=E5=90=8C=E3=81=98=E3=82=82=E3=81=AE?= =?UTF-8?q?=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=BE=E3=81=99?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view.py | 5 +++- vrct_gui/_CreateConfirmationModal.py | 33 ++++++++++++++++++++++++-- vrct_gui/splash_window/SplashWindow.py | 27 +++++---------------- vrct_gui/ui_utils/ui_utils.py | 16 +++++++++++++ 4 files changed, 57 insertions(+), 24 deletions(-) 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], "+")