[Update] UI追加 初期起動時の言語モデルダウンロード中、splash画面にプログレスバー表示。

This commit is contained in:
Sakamoto Shiina
2023-11-29 17:11:47 +09:00
parent 52abfb8a97
commit 69f6e44720
3 changed files with 34 additions and 2 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -9,7 +9,7 @@ if __name__ == "__main__":
from config import config
from models.translation.utils import downloadCTranslate2Weight
downloadCTranslate2Weight(config.PATH_LOCAL, config.WEIGHT_TYPE, config.CTRANSLATE2_WEIGHTS, print)
downloadCTranslate2Weight(config.PATH_LOCAL, config.WEIGHT_TYPE, config.CTRANSLATE2_WEIGHTS, splash.updateDownloadProgress)
import controller
controller.createMainWindow()

View File

@@ -1,4 +1,4 @@
from customtkinter import CTkImage, CTkLabel, CTkToplevel
from customtkinter import CTkImage, CTkLabel, CTkToplevel, CTkProgressBar
from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation
class SplashWindow(CTkToplevel):
@@ -10,6 +10,7 @@ class SplashWindow(CTkToplevel):
self.title("SplashWindow")
self.wm_attributes("-toolwindow", True)
self.is_showed_progressbar = False
sw=self.winfo_screenwidth()
@@ -28,6 +29,37 @@ class SplashWindow(CTkToplevel):
label.grid(row=1, column=1, padx=int(desired_width/7), pady=int(height/3))
self.progressbar_widget = CTkProgressBar(
self,
height=10,
corner_radius=0,
fg_color="#4b4c4f",
progress_color="#48a495",
)
self.progressbar_widget.set(0)
(img, desired_width, height) = openImageKeepAspectRatio(getImageFileFromUiUtils("VRCT_now_downloading.png"), 320)
self.text_label = CTkLabel(
self,
text=None,
height=0,
fg_color="#292a2d",
image=CTkImage(img, size=(desired_width, height))
)
def updateDownloadProgress(self, progress:float):
if self.is_showed_progressbar is False:
self.progressbar_widget.place(relwidth=0.9, relx=0.5, rely=0.9, anchor="s")
self.text_label.place(relx=0.98, rely=0.98, anchor="se")
self.is_showed_progressbar = True
self.progressbar_widget.set(progress)
self.update_idletasks()
def showSplash(self):
self.attributes("-alpha", 0)
self.deiconify()