diff --git a/main.py b/main.py index 103e09c3..b3801625 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,10 @@ +from vrct_gui.splash_window import SplashWindow +splash = SplashWindow() +splash.showSplash() + import controller if __name__ == "__main__": controller.createMainWindow() + splash.destroySplash() controller.showMainWindow() \ No newline at end of file diff --git a/view.py b/view.py index cc77c545..7608a161 100644 --- a/view.py +++ b/view.py @@ -864,6 +864,17 @@ class View(): def clearErrorMessage(self): vrct_gui._clearErrorMessage() + + + + @staticmethod + def showSplash(): + vrct_gui.showSplash() + + @staticmethod + def destroySplash(): + vrct_gui.destroySplash() + # These conversations are generated by ChatGPT def _insertSampleConversationToTextbox(self): diff --git a/vrct_gui/splash_window/SplashWindow.py b/vrct_gui/splash_window/SplashWindow.py new file mode 100644 index 00000000..374323eb --- /dev/null +++ b/vrct_gui/splash_window/SplashWindow.py @@ -0,0 +1,51 @@ +from customtkinter import CTkImage, CTkLabel, CTkToplevel +from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils +from time import sleep + +class SplashWindow(CTkToplevel): + def __init__(self): + super().__init__() + self.withdraw() + self.overrideredirect(True) + self.configure(fg_color="#292a2d") + self.title("SplashWindow") + + + sw=self.winfo_screenwidth() + sh=self.winfo_screenheight() + + pw=int(sw/4) + + self.grid_columnconfigure((0,2), weight=1) + self.grid_rowconfigure((0,2), weight=1) + (img, desired_width, height) = openImageKeepAspectRatio(getImageFileFromUiUtils("vrct_logo_for_dark_mode.png"), pw) + label = CTkLabel( + self, + text=None, + height=0, + 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)) + + + + def showSplash(self): + 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) + + + def destroySplash(self): + self.destroy() \ No newline at end of file diff --git a/vrct_gui/splash_window/__init__.py b/vrct_gui/splash_window/__init__.py new file mode 100644 index 00000000..3ce5e580 --- /dev/null +++ b/vrct_gui/splash_window/__init__.py @@ -0,0 +1 @@ +from .SplashWindow import * \ No newline at end of file