From 3e6bce367c5de8fa3c01292ed6b1a64529a4aa00 Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Wed, 11 Oct 2023 23:11:59 +0900 Subject: [PATCH] =?UTF-8?q?[Update]=20=E5=90=84Window=E8=A1=A8=E7=A4=BA?= =?UTF-8?q?=E6=99=82=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=AE=E4=B8=AD=E5=A4=AE?= =?UTF-8?q?=E3=81=AB=E9=85=8D=E7=BD=AE=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=80=82(=E3=81=9D=E3=82=8C=E3=81=AB=E3=82=88?= =?UTF-8?q?=E3=81=A3=E3=81=A6=E4=B8=80=E7=9E=AC=E5=86=8D=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E3=81=8C=E8=A6=8B=E3=81=88=E3=82=8B=E3=81=AE=E3=81=A7=E3=80=81?= =?UTF-8?q?=E8=AA=A4=E9=AD=94=E5=8C=96=E3=81=97=E7=94=A8=E3=81=A7=E3=82=82?= =?UTF-8?q?=E3=81=82=E3=82=8B)=E3=83=95=E3=82=A7=E3=83=BC=E3=83=89?= =?UTF-8?q?=E3=82=A4=E3=83=B3=E3=82=A2=E3=83=8B=E3=83=A1=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E8=BF=BD=E5=8A=A0=E3=81=A8=E3=81=9D=E3=82=8C?= =?UTF-8?q?=E3=82=89=E9=96=A2=E6=95=B0=E3=81=AE=E6=B1=8E=E7=94=A8=E5=8C=96?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_CreateModalWindow.py | 2 +- vrct_gui/splash_window/SplashWindow.py | 24 ++++++--------------- vrct_gui/ui_utils/ui_utils.py | 29 +++++++++++++++++++++++++- vrct_gui/vrct_gui.py | 17 ++++++++++++--- 4 files changed, 49 insertions(+), 23 deletions(-) diff --git a/vrct_gui/_CreateModalWindow.py b/vrct_gui/_CreateModalWindow.py index 2e4ba26b..8cd837c2 100644 --- a/vrct_gui/_CreateModalWindow.py +++ b/vrct_gui/_CreateModalWindow.py @@ -9,7 +9,7 @@ class _CreateModalWindow(CTkToplevel): self.title("") self.overrideredirect(True) - self.wm_attributes("-alpha", 0.5) + # self.wm_attributes("-alpha", 0.5) self.wm_attributes("-toolwindow", True) self.attach_window = attach_window diff --git a/vrct_gui/splash_window/SplashWindow.py b/vrct_gui/splash_window/SplashWindow.py index 374323eb..d5e1d2e7 100644 --- a/vrct_gui/splash_window/SplashWindow.py +++ b/vrct_gui/splash_window/SplashWindow.py @@ -1,6 +1,5 @@ from customtkinter import CTkImage, CTkLabel, CTkToplevel -from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils -from time import sleep +from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation class SplashWindow(CTkToplevel): def __init__(self): @@ -12,7 +11,7 @@ class SplashWindow(CTkToplevel): sw=self.winfo_screenwidth() - sh=self.winfo_screenheight() + # sh=self.winfo_screenheight() pw=int(sw/4) @@ -26,25 +25,14 @@ class SplashWindow(CTkToplevel): fg_color="#292a2d", image=CTkImage(img, size=(desired_width, height)) ) - label.grid(row=1, column=1) - - geometry_width=desired_width+int(desired_width*0.2) - geometry_height=height+int(height*0.5) - - self.geometry(str(geometry_width)+"x"+str(geometry_height)+"+"+str((sw-geometry_width)//2)+"+"+str((sh-geometry_height)//2)) - + label.grid(row=1, column=1, padx=int(desired_width/7), pady=int(height/3)) def showSplash(self): + self.attributes("-alpha", 0) self.deiconify() - - for i in range(0,91,20): - if not self.winfo_exists(): - break - self.attributes("-alpha", i/100) - self.update() - sleep(1/50) - self.attributes("-alpha", 1) + setGeometryToCenterOfScreen(root_widget=self) + fadeInAnimation(self, steps=5, interval=0.02) def destroySplash(self): diff --git a/vrct_gui/ui_utils/ui_utils.py b/vrct_gui/ui_utils/ui_utils.py index 9b0b5671..5dff06b9 100644 --- a/vrct_gui/ui_utils/ui_utils.py +++ b/vrct_gui/ui_utils/ui_utils.py @@ -1,5 +1,6 @@ from os import path as os_path from PIL.Image import open as Image_open, LANCZOS +from time import sleep from customtkinter import CTkFrame, CTkLabel, CTkImage, CTkFont @@ -199,4 +200,30 @@ def applyUiScalingAndFixTheBugScrollBar(scrollbar_widget, padx, width): # This is for CustomTkinter's spec change or bug fix. scrollbar_widget._scrollbar.configure(height=0) - scrollbar_widget._scrollbar.configure(width=width) \ No newline at end of file + scrollbar_widget._scrollbar.configure(width=width) + + +def setGeometryToCenterOfScreen(root_widget): + root_widget.update() + sw=root_widget.winfo_screenwidth() + sh=root_widget.winfo_screenheight() + geometry_width = root_widget.winfo_width() + geometry_height = root_widget.winfo_height() + + root_widget.geometry(str(geometry_width)+"x"+str(geometry_height)+"+"+str((sw-geometry_width)//2)+"+"+str((sh-geometry_height)//2)) + + +def fadeInAnimation(root_widget, steps:int=10, interval:float=0.1, max_alpha:float=1): + alpha_steps = 100 + alpha_steps*=max_alpha + step_size = alpha_steps/steps + root_widget.attributes("-alpha", 0) + num = 0 + while num < alpha_steps: + if not root_widget.winfo_exists(): + break + root_widget.attributes("-alpha", num / 100) + root_widget.update() + sleep(interval) + num += step_size + root_widget.attributes("-alpha", max_alpha) \ No newline at end of file diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index ce96b23e..844c029a 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -11,7 +11,7 @@ from ._printToTextbox import _printToTextbox from .main_window import createMainWindowWidgets from .config_window import ConfigWindow -from .ui_utils import _setDefaultActiveTab, getLatestHeight +from .ui_utils import _setDefaultActiveTab, getLatestHeight, setGeometryToCenterOfScreen, fadeInAnimation from utils import callFunctionIfCallable @@ -20,14 +20,16 @@ class VRCT_GUI(CTk): super().__init__() self.withdraw() self.adjusted_event=None + self.is_config_window_already_opened_once=False self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID=None self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID=None def _showGUI(self): + self.attributes("-alpha", 0) self.deiconify() - self.update() - self.geometry("{}x{}".format(self.winfo_width(), self.winfo_height())) + setGeometryToCenterOfScreen(root_widget=self) + fadeInAnimation(self, steps=5, interval=0.008) def _createGUI(self, settings, view_variable): self.settings = settings @@ -109,11 +111,20 @@ class VRCT_GUI(CTk): callFunctionIfCallable(self._view_variable.CALLBACK_OPEN_CONFIG_WINDOW) self._adjustToMainWindowGeometry() + self.modal_window.attributes("-alpha", 0) self.modal_window.deiconify() + fadeInAnimation(self.modal_window, steps=5, interval=0.005, max_alpha=0.5) + self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.bind("", self._adjustToMainWindowGeometry, "+") self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID = self.modal_window.bind("", lambda _e: self.config_window.lift(), "+") + self.config_window.attributes("-alpha", 0) self.config_window.deiconify() + if self.is_config_window_already_opened_once is False: + setGeometryToCenterOfScreen(self.config_window) + self.is_config_window_already_opened_once = True + fadeInAnimation(self.config_window, steps=5, interval=0.005) + self.config_window.attributes("-alpha", 1) self.config_window.focus_set() def _closeConfigWindow(self):