[Update] UI追加 初期起動時の言語モデルダウンロード中、splash画面にプログレスバー表示。
This commit is contained in:
BIN
img/VRCT_now_downloading.png
Normal file
BIN
img/VRCT_now_downloading.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
2
main.py
2
main.py
@@ -9,7 +9,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
from models.translation.utils import downloadCTranslate2Weight
|
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
|
import controller
|
||||||
controller.createMainWindow()
|
controller.createMainWindow()
|
||||||
|
|||||||
@@ -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
|
from ..ui_utils import openImageKeepAspectRatio, getImageFileFromUiUtils, setGeometryToCenterOfScreen, fadeInAnimation
|
||||||
|
|
||||||
class SplashWindow(CTkToplevel):
|
class SplashWindow(CTkToplevel):
|
||||||
@@ -10,6 +10,7 @@ class SplashWindow(CTkToplevel):
|
|||||||
self.title("SplashWindow")
|
self.title("SplashWindow")
|
||||||
self.wm_attributes("-toolwindow", True)
|
self.wm_attributes("-toolwindow", True)
|
||||||
|
|
||||||
|
self.is_showed_progressbar = False
|
||||||
|
|
||||||
sw=self.winfo_screenwidth()
|
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))
|
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):
|
def showSplash(self):
|
||||||
self.attributes("-alpha", 0)
|
self.attributes("-alpha", 0)
|
||||||
self.deiconify()
|
self.deiconify()
|
||||||
|
|||||||
Reference in New Issue
Block a user