[Update] 各Window表示時に画面の中央に配置するように。(それによって一瞬再配置が見えるので、誤魔化し用でもある)フェードインアニメーション追加とそれら関数の汎用化。

This commit is contained in:
Sakamoto Shiina
2023-10-11 23:11:59 +09:00
parent 8185050ea2
commit 3e6bce367c
4 changed files with 49 additions and 23 deletions

View File

@@ -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):