From b77afccf540027c6ad092d623e16b554294079e7 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 2 Jun 2023 12:09:42 +0900 Subject: [PATCH 1/8] slider for transparency --- VRCT.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/VRCT.py b/VRCT.py index cc7ce739..d6e24c28 100644 --- a/VRCT.py +++ b/VRCT.py @@ -19,6 +19,7 @@ AUTH_KEY = None TRANSLATOR = None MESSAGE_FORMAT = "[message]([translation])" FONT_FAMILY = "Yu Gothic UI" +TRANSPARENCY = 100 # load config if os.path.isfile(PATH_CONFIG) is not False: @@ -41,7 +42,9 @@ if os.path.isfile(PATH_CONFIG) is not False: if "MESSAGE_FORMAT" in config.keys(): MESSAGE_FORMAT = config["MESSAGE_FORMAT"] if "FONT_FAMILY" in config.keys(): - MESSAGE_FORMAT = config["FONT_FAMILY"] + FONT_FAMILY = config["FONT_FAMILY"] + if "TRANSPARENCY" in config.keys(): + TRANSPARENCY = config["TRANSPARENCY"] with open(PATH_CONFIG, 'w') as fp: config = { @@ -53,6 +56,8 @@ with open(PATH_CONFIG, 'w') as fp: "ENABLE_FOREGROUND": ENABLE_FOREGROUND, "AUTH_KEY": AUTH_KEY, "MESSAGE_FORMAT": MESSAGE_FORMAT, + "FONT_FAMILY": FONT_FAMILY, + "TRANSPARENCY": TRANSPARENCY, } json.dump(config, fp, indent=4) @@ -74,7 +79,7 @@ class ToplevelWindow_information(customtkinter.CTkToplevel): self.parent = parent self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) - self.geometry(f"{500}x{300}") + # self.geometry(f"{500}x{300}") self.minsize(500, 300) self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) @@ -138,7 +143,7 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent - self.geometry(f"{450}x{160}") + # self.geometry(f"{450}x{200}") self.resizable(False, False) self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) @@ -149,7 +154,7 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): self.entry_ip_address.grid(row=0, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_ip_address = customtkinter.CTkButton(self, text="", width=1, command=self.update_ip_address, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))),) - self.button_ip_address.grid(row=0, column=2, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_ip_address.grid(row=0, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") self.label_port = customtkinter.CTkLabel(self, text="OSC Port:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) self.label_port.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") @@ -157,7 +162,7 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): self.entry_port.grid(row=1, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_port = customtkinter.CTkButton(self, text="", width=1, command=self.update_port, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_port.grid(row=1, column=2, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_port.grid(row=1, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") self.label_authkey = customtkinter.CTkLabel(self, text="DeepL Auth Key:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) self.label_authkey.grid(row=2, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") @@ -165,7 +170,7 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): self.entry_authkey.grid(row=2, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_authkey = customtkinter.CTkButton(self, text="", width=1, command=self.update_authkey, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_authkey.grid(row=2, column=2, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_authkey.grid(row=2, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") self.label_message_format = customtkinter.CTkLabel(self, text="Message Format:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) self.label_message_format.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") @@ -173,7 +178,13 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): self.entry_message_format.grid(row=3, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_message_format = customtkinter.CTkButton(self, text="", width=1, command=self.update_message_format, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_message_format.grid(row=3, column=2, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_message_format.grid(row=3, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + + self.label_transparency = customtkinter.CTkLabel(self, text="Transparency:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_transparency.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.slider_transparency = customtkinter.CTkSlider(self, from_=50, to=100, command=self.update_transparency) + self.slider_transparency.grid(row=4, column=1, columnspan=2, padx=10, pady=10, sticky="nsew") + self.slider_transparency.set(TRANSPARENCY) def update_ip_address(self): value = self.entry_ip_address.get() @@ -233,6 +244,16 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): with open(PATH_CONFIG, "w") as fp: json.dump(config, fp, indent=4) + def update_transparency(self, value): + global TRANSPARENCY + TRANSPARENCY = value + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["TRANSPARENCY"] = TRANSPARENCY + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + self.parent.wm_attributes("-alpha", TRANSPARENCY/100) + class App(customtkinter.CTk): def __init__(self): super().__init__() @@ -322,6 +343,7 @@ class App(customtkinter.CTk): self.combobox_language.set(TARGET_LANG) self.combobox_translator.set(CHOICE_TRANSLATOR) + self.wm_attributes("-alpha", TRANSPARENCY/100) def open_config(self): if self.config_window is None or not self.config_window.winfo_exists(): From 6412f7df5a55bc4e23deec6424768fc85c564e2d Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 2 Jun 2023 15:05:00 +0900 Subject: [PATCH 2/8] =?UTF-8?q?=E3=83=88=E3=83=83=E3=83=97=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=82=92=E7=B0=A1=E7=B4=A0=E3=81=AB=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 146 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 78 insertions(+), 68 deletions(-) diff --git a/VRCT.py b/VRCT.py index d6e24c28..4bfff0f2 100644 --- a/VRCT.py +++ b/VRCT.py @@ -73,7 +73,7 @@ if AUTH_KEY is not None: customtkinter.set_appearance_mode("System") customtkinter.set_default_color_theme("blue") -class ToplevelWindow_information(customtkinter.CTkToplevel): +class ToplevelWindowInformation(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(*args, **kwargs) self.parent = parent @@ -139,7 +139,7 @@ https://twitter.com/misya_ai self.textbox_information.insert("0.0", textbox_information_message) self.textbox_information.configure(state='disabled') -class ToplevelWindow_config(customtkinter.CTkToplevel): +class ToplevelWindowConfig(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent @@ -148,43 +148,73 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) self.title("Config") + + # combobox translator + self.label_translator = customtkinter.CTkLabel(self, text="select translator:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_translator.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.combobox_translator = customtkinter.CTkComboBox(self, + command=self.combobox_translator_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.combobox_translator.grid(row=0, column=1, columnspan=2 ,padx=(0, 5), pady=5, sticky="nsew") + self.combobox_translator.configure(values=["DeepL"],) + self.combobox_translator.set(CHOICE_TRANSLATOR) + + # combobox language + self.label_language = customtkinter.CTkLabel(self, text="select language:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_language.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.combobox_language = customtkinter.CTkComboBox(self, + command=self.combobox_language_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.combobox_language.grid(row=1, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") + self.combobox_language.configure(values=[ + "JA","BG","CS","DA","DE","EL","EN","EN-US","EN-GB","ES","ET","FI","FR","HU", + "ID","IT","KO","LT","LV","NB","NL","PL","PT","PT-BR","PT-PT","RO","RU","SK", + "SL","SV","TR","UK","ZH", + ],) + self.combobox_language.set(TARGET_LANG) + + # slider transparency + self.label_transparency = customtkinter.CTkLabel(self, text="Transparency:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_transparency.grid(row=2, column=0, columnspan=1, padx=(0, 5), pady=5, sticky="nsew") + self.slider_transparency = customtkinter.CTkSlider(self, from_=50, to=100, command=self.slider_transparency_callback) + self.slider_transparency.grid(row=2, column=1, columnspan=2, padx=5, pady=10, sticky="nsew") + self.slider_transparency.set(TRANSPARENCY) + + # entry ip address self.label_ip_address = customtkinter.CTkLabel(self, text="OSC IP address:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_ip_address.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_ip_address.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") self.entry_ip_address = customtkinter.CTkEntry(self, width=300, placeholder_text=OSC_IP_ADDRESS, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_ip_address.grid(row=0, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.entry_ip_address.grid(row=3, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_ip_address = customtkinter.CTkButton(self, text="", width=1, command=self.update_ip_address, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))),) - self.button_ip_address.grid(row=0, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.button_ip_address.grid(row=3, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + # entry port self.label_port = customtkinter.CTkLabel(self, text="OSC Port:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_port.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_port.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") self.entry_port = customtkinter.CTkEntry(self, placeholder_text=OSC_PORT, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_port.grid(row=1, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.entry_port.grid(row=4, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_port = customtkinter.CTkButton(self, text="", width=1, command=self.update_port, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_port.grid(row=1, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.button_port.grid(row=4, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + # entry authkey self.label_authkey = customtkinter.CTkLabel(self, text="DeepL Auth Key:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_authkey.grid(row=2, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_authkey.grid(row=5, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") self.entry_authkey = customtkinter.CTkEntry(self, placeholder_text=AUTH_KEY, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_authkey.grid(row=2, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.entry_authkey.grid(row=5, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_authkey = customtkinter.CTkButton(self, text="", width=1, command=self.update_authkey, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_authkey.grid(row=2, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.button_authkey.grid(row=5, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + # entry message format self.label_message_format = customtkinter.CTkLabel(self, text="Message Format:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_message_format.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_message_format.grid(row=6, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") self.entry_message_format = customtkinter.CTkEntry(self, placeholder_text=MESSAGE_FORMAT, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_message_format.grid(row=3, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.entry_message_format.grid(row=6, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") self.button_message_format = customtkinter.CTkButton(self, text="", width=1, command=self.update_message_format, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_message_format.grid(row=3, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") - - self.label_transparency = customtkinter.CTkLabel(self, text="Transparency:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_transparency.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.slider_transparency = customtkinter.CTkSlider(self, from_=50, to=100, command=self.update_transparency) - self.slider_transparency.grid(row=4, column=1, columnspan=2, padx=10, pady=10, sticky="nsew") - self.slider_transparency.set(TRANSPARENCY) + self.button_message_format.grid(row=6, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") def update_ip_address(self): value = self.entry_ip_address.get() @@ -244,7 +274,7 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): with open(PATH_CONFIG, "w") as fp: json.dump(config, fp, indent=4) - def update_transparency(self, value): + def slider_transparency_callback(self, value): global TRANSPARENCY TRANSPARENCY = value with open(PATH_CONFIG, "r") as fp: @@ -254,13 +284,31 @@ class ToplevelWindow_config(customtkinter.CTkToplevel): json.dump(config, fp, indent=4) self.parent.wm_attributes("-alpha", TRANSPARENCY/100) + def combobox_translator_callback(self, choice): + global CHOICE_TRANSLATOR + CHOICE_TRANSLATOR = choice + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["CHOICE_TRANSLATOR"] = CHOICE_TRANSLATOR + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + + def combobox_language_callback(self, choice): + global TARGET_LANG + TARGET_LANG = choice + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["TARGET_LANG"] = TARGET_LANG + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + class App(customtkinter.CTk): def __init__(self): super().__init__() self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico")) self.title("VRCT") - self.geometry(f"{400}x{190}") - self.minsize(400, 190) + self.geometry(f"{400}x{120}") + self.minsize(400, 120) self.grid_columnconfigure(1, weight=1) self.grid_rowconfigure(0, weight=1) @@ -281,26 +329,14 @@ class App(customtkinter.CTk): font=customtkinter.CTkFont(family=FONT_FAMILY)) self.checkbox_foreground.grid(row=1, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") - # combobox translator - self.combobox_translator = customtkinter.CTkComboBox(self.sidebar_frame, - command=self.combobox_translator_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.combobox_translator.grid(row=2, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") - - # combobox language - self.combobox_language = customtkinter.CTkComboBox(self.sidebar_frame, - command=self.combobox_language_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.combobox_language.grid(row=3, column=0, columnspan=2, padx=10, pady=(5, 5), sticky="we") - # button information - self.button_information = customtkinter.CTkButton(self.sidebar_frame, text="", width=70, command=self.open_information, + self.button_information = customtkinter.CTkButton(self.sidebar_frame, text="", width=25, command=self.open_information, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "info-icon-white.png")))) self.button_information.grid(row=5, column=0, padx=(10, 5), pady=(10, 10), sticky="wse") self.information_window = None # button config - self.button_config = customtkinter.CTkButton(self.sidebar_frame, text="", width=70, command=self.open_config, + self.button_config = customtkinter.CTkButton(self.sidebar_frame, text="", width=25, command=self.open_config, image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "config-icon-white.png")))) self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(10, 10), sticky="wse") self.config_window = None @@ -327,13 +363,7 @@ class App(customtkinter.CTk): self.checkbox_foreground.deselect() self.attributes("-topmost", False) - self.combobox_translator.configure(values=["DeepL"],) - self.combobox_language.configure(values=[ - "JA","BG","CS","DA","DE","EL","EN","EN-US","EN-GB","ES","ET","FI","FR","HU", - "ID","IT","KO","LT","LV","NB","NL","PL","PT","PT-BR","PT-PT","RO","RU","SK", - "SL","SV","TR","UK","ZH", - ],) - self.entry_message_box.bind("", self.press_key) + self.entry_message_box.bind("", self.entry_message_box_press_key_enter) if TRANSLATOR is None: # error update Auth key @@ -341,18 +371,16 @@ class App(customtkinter.CTk): self.textbox_message_log.insert("0.0", f"Auth Keyを設定してないか間違っています\n") self.textbox_message_log.configure(state='disabled') - self.combobox_language.set(TARGET_LANG) - self.combobox_translator.set(CHOICE_TRANSLATOR) self.wm_attributes("-alpha", TRANSPARENCY/100) def open_config(self): if self.config_window is None or not self.config_window.winfo_exists(): - self.config_window = ToplevelWindow_config(self) + self.config_window = ToplevelWindowConfig(self) self.config_window.focus() def open_information(self): if self.information_window is None or not self.information_window.winfo_exists(): - self.information_window = ToplevelWindow_information(self) + self.information_window = ToplevelWindowInformation(self) self.information_window.focus() def checkbox_translation_callback(self): @@ -364,24 +392,6 @@ class App(customtkinter.CTk): with open(PATH_CONFIG, "w") as fp: json.dump(config, fp, indent=4) - def combobox_translator_callback(self, choice): - global CHOICE_TRANSLATOR - CHOICE_TRANSLATOR = choice - with open(PATH_CONFIG, "r") as fp: - config = json.load(fp) - config["CHOICE_TRANSLATOR"] = CHOICE_TRANSLATOR - with open(PATH_CONFIG, "w") as fp: - json.dump(config, fp, indent=4) - - def combobox_language_callback(self, choice): - global TARGET_LANG - TARGET_LANG = choice - with open(PATH_CONFIG, "r") as fp: - config = json.load(fp) - config["TARGET_LANG"] = TARGET_LANG - with open(PATH_CONFIG, "w") as fp: - json.dump(config, fp, indent=4) - def checkbox_foreground_callback(self): global ENABLE_FOREGROUND ENABLE_FOREGROUND = self.checkbox_foreground.get() @@ -396,14 +406,14 @@ class App(customtkinter.CTk): else: self.attributes("-topmost", False) - def press_key(self, event): + def entry_message_box_press_key_enter(self, event): if TRANSLATOR is None: pass else: message = self.entry_message_box.get() # translate - if self.checkbox_translation.get() is True: + if self.checkbox_translation.get() is True and len(message) > 0: result = TRANSLATOR.translate_text(message, target_lang=TARGET_LANG) chat_message = MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result.text) else: From 1c4f06af815e343f76038821d216613cb7a18a7c Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Fri, 2 Jun 2023 15:44:34 +0900 Subject: [PATCH 3/8] add tabview for config --- VRCT.py | 174 +++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 133 insertions(+), 41 deletions(-) diff --git a/VRCT.py b/VRCT.py index 4bfff0f2..15d98837 100644 --- a/VRCT.py +++ b/VRCT.py @@ -143,78 +143,170 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent - # self.geometry(f"{450}x{200}") + self.geometry(f"{350}x{220}") self.resizable(False, False) + self.grid_columnconfigure(0, weight=1) + self.grid_rowconfigure(0, weight=1) self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) self.title("Config") + # tabwiew config + self.tabview_config = customtkinter.CTkTabview(self) + self.tabview_config.grid(row=0, column=0, padx=5, pady=5, sticky="nsew") + self.tabview_config.add("GUI") + self.tabview_config.add("Parameter") + self.tabview_config.tab("GUI").grid_columnconfigure(0, weight=1) + self.tabview_config.tab("Parameter").grid_columnconfigure(0, weight=1) + # combobox translator - self.label_translator = customtkinter.CTkLabel(self, text="select translator:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_translator = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="select translator:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.label_translator.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.combobox_translator = customtkinter.CTkComboBox(self, - command=self.combobox_translator_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.combobox_translator = customtkinter.CTkComboBox( + self.tabview_config.tab("GUI"), + command=self.combobox_translator_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.combobox_translator.grid(row=0, column=1, columnspan=2 ,padx=(0, 5), pady=5, sticky="nsew") self.combobox_translator.configure(values=["DeepL"],) self.combobox_translator.set(CHOICE_TRANSLATOR) # combobox language - self.label_language = customtkinter.CTkLabel(self, text="select language:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_language = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="select language:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.label_language.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.combobox_language = customtkinter.CTkComboBox(self, - command=self.combobox_language_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.combobox_language = customtkinter.CTkComboBox( + self.tabview_config.tab("GUI"), + command=self.combobox_language_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.combobox_language.grid(row=1, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") - self.combobox_language.configure(values=[ + self.combobox_language.configure( + values=[ "JA","BG","CS","DA","DE","EL","EN","EN-US","EN-GB","ES","ET","FI","FR","HU", "ID","IT","KO","LT","LV","NB","NL","PL","PT","PT-BR","PT-PT","RO","RU","SK", "SL","SV","TR","UK","ZH", - ],) + ] + ) self.combobox_language.set(TARGET_LANG) # slider transparency - self.label_transparency = customtkinter.CTkLabel(self, text="Transparency:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_transparency = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="Transparency:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.label_transparency.grid(row=2, column=0, columnspan=1, padx=(0, 5), pady=5, sticky="nsew") - self.slider_transparency = customtkinter.CTkSlider(self, from_=50, to=100, command=self.slider_transparency_callback) + self.slider_transparency = customtkinter.CTkSlider( + self.tabview_config.tab("GUI"), + from_=50, + to=100, + command=self.slider_transparency_callback + ) self.slider_transparency.grid(row=2, column=1, columnspan=2, padx=5, pady=10, sticky="nsew") self.slider_transparency.set(TRANSPARENCY) # entry ip address - self.label_ip_address = customtkinter.CTkLabel(self, text="OSC IP address:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_ip_address.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.entry_ip_address = customtkinter.CTkEntry(self, width=300, placeholder_text=OSC_IP_ADDRESS, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_ip_address.grid(row=3, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") - self.button_ip_address = customtkinter.CTkButton(self, text="", width=1, command=self.update_ip_address, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))),) - self.button_ip_address.grid(row=3, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_ip_address = customtkinter.CTkLabel( + self.tabview_config.tab("Parameter"), + text="OSC IP address:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_ip_address.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.entry_ip_address = customtkinter.CTkEntry( + self.tabview_config.tab("Parameter"), + placeholder_text=OSC_IP_ADDRESS, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.entry_ip_address.grid(row=0, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_ip_address = customtkinter.CTkButton( + self.tabview_config.tab("Parameter"), + text="", + width=1, + command=self.update_ip_address, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))) + ) + self.button_ip_address.grid(row=0, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") # entry port - self.label_port = customtkinter.CTkLabel(self, text="OSC Port:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_port.grid(row=4, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.entry_port = customtkinter.CTkEntry(self, placeholder_text=OSC_PORT, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_port.grid(row=4, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") - self.button_port = customtkinter.CTkButton(self, text="", width=1, command=self.update_port, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_port.grid(row=4, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_port = customtkinter.CTkLabel( + self.tabview_config.tab("Parameter"), + text="OSC Port:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_port.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.entry_port = customtkinter.CTkEntry( + self.tabview_config.tab("Parameter"), + placeholder_text=OSC_PORT, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.entry_port.grid(row=1, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_port = customtkinter.CTkButton( + self.tabview_config.tab("Parameter"), + text="", + width=1, + command=self.update_port, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))) + ) + self.button_port.grid(row=1, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") # entry authkey - self.label_authkey = customtkinter.CTkLabel(self, text="DeepL Auth Key:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_authkey.grid(row=5, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.entry_authkey = customtkinter.CTkEntry(self, placeholder_text=AUTH_KEY, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_authkey.grid(row=5, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") - self.button_authkey = customtkinter.CTkButton(self, text="", width=1, command=self.update_authkey, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_authkey.grid(row=5, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_authkey = customtkinter.CTkLabel( + self.tabview_config.tab("Parameter"), + text="DeepL Auth Key:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_authkey.grid(row=2, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.entry_authkey = customtkinter.CTkEntry( + self.tabview_config.tab("Parameter"), + placeholder_text=AUTH_KEY, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.entry_authkey.grid(row=2, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_authkey = customtkinter.CTkButton( + self.tabview_config.tab("Parameter"), + text="", + width=1, + command=self.update_authkey, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))) + ) + self.button_authkey.grid(row=2, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") # entry message format - self.label_message_format = customtkinter.CTkLabel(self, text="Message Format:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.label_message_format.grid(row=6, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.entry_message_format = customtkinter.CTkEntry(self, placeholder_text=MESSAGE_FORMAT, font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.entry_message_format.grid(row=6, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") - self.button_message_format = customtkinter.CTkButton(self, text="", width=1, command=self.update_message_format, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png")))) - self.button_message_format.grid(row=6, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") + self.label_message_format = customtkinter.CTkLabel( + self.tabview_config.tab("Parameter"), + text="Message Format:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_message_format.grid(row=3, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") + self.entry_message_format = customtkinter.CTkEntry( + self.tabview_config.tab("Parameter"), + placeholder_text=MESSAGE_FORMAT, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.entry_message_format.grid(row=3, column=1, columnspan=1, padx=1, pady=5, sticky="nsew") + self.button_message_format = customtkinter.CTkButton( + self.tabview_config.tab("Parameter"), + text="", + width=1, + command=self.update_message_format, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "save-icon.png"))) + ) + self.button_message_format.grid(row=3, column=2, columnspan=1, padx=5, pady=5, sticky="nsew") def update_ip_address(self): value = self.entry_ip_address.get() From de782e10425840f6333c57a0e7e15a17f5037f70 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 3 Jun 2023 00:45:37 +0900 Subject: [PATCH 4/8] update UI --- VRCT.py | 223 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 183 insertions(+), 40 deletions(-) diff --git a/VRCT.py b/VRCT.py index 15d98837..ef6674ae 100644 --- a/VRCT.py +++ b/VRCT.py @@ -20,6 +20,8 @@ TRANSLATOR = None MESSAGE_FORMAT = "[message]([translation])" FONT_FAMILY = "Yu Gothic UI" TRANSPARENCY = 100 +APPEARANCE_THEME = "System" +UI_SCALING = "100%" # load config if os.path.isfile(PATH_CONFIG) is not False: @@ -45,6 +47,10 @@ if os.path.isfile(PATH_CONFIG) is not False: FONT_FAMILY = config["FONT_FAMILY"] if "TRANSPARENCY" in config.keys(): TRANSPARENCY = config["TRANSPARENCY"] + if "APPEARANCE_THEME" in config.keys(): + APPEARANCE_THEME = config["APPEARANCE_THEME"] + if "UI_SCALING" in config.keys(): + UI_SCALING = config["UI_SCALING"] with open(PATH_CONFIG, 'w') as fp: config = { @@ -58,6 +64,8 @@ with open(PATH_CONFIG, 'w') as fp: "MESSAGE_FORMAT": MESSAGE_FORMAT, "FONT_FAMILY": FONT_FAMILY, "TRANSPARENCY": TRANSPARENCY, + "APPEARANCE_THEME": APPEARANCE_THEME, + "UI_SCALING": UI_SCALING, } json.dump(config, fp, indent=4) @@ -70,12 +78,12 @@ if AUTH_KEY is not None: TRANSLATOR = None # GUI -customtkinter.set_appearance_mode("System") +customtkinter.set_appearance_mode(APPEARANCE_THEME) customtkinter.set_default_color_theme("blue") class ToplevelWindowInformation(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): - super().__init__(*args, **kwargs) + super().__init__(parent, *args, **kwargs) self.parent = parent self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) @@ -85,7 +93,10 @@ class ToplevelWindowInformation(customtkinter.CTkToplevel): self.after(200, lambda: self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico"))) self.title("Information") # create textbox information - self.textbox_information = customtkinter.CTkTextbox(self, font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.textbox_information = customtkinter.CTkTextbox( + self, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.textbox_information.grid(row=0, column=0, padx=(10, 10), pady=(10, 10), sticky="nsew") textbox_information_message = """VRCT(v0.2b) @@ -143,8 +154,8 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): def __init__(self, parent, *args, **kwargs): super().__init__(parent, *args, **kwargs) self.parent = parent - self.geometry(f"{350}x{220}") - self.resizable(False, False) + # self.geometry(f"{350}x{270}") + # self.resizable(False, False) self.grid_columnconfigure(0, weight=1) self.grid_rowconfigure(0, weight=1) @@ -158,46 +169,47 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.tabview_config.add("Parameter") self.tabview_config.tab("GUI").grid_columnconfigure(0, weight=1) self.tabview_config.tab("Parameter").grid_columnconfigure(0, weight=1) + self.tabview_config._segmented_button.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) - # combobox translator + # optionmenu translator self.label_translator = customtkinter.CTkLabel( self.tabview_config.tab("GUI"), - text="select translator:", + text="Select Translator:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY) ) self.label_translator.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.combobox_translator = customtkinter.CTkComboBox( + self.optionmenu_translator = customtkinter.CTkOptionMenu( self.tabview_config.tab("GUI"), - command=self.combobox_translator_callback, + values=["DeepL"], + command=self.optionmenu_translator_callback, font=customtkinter.CTkFont(family=FONT_FAMILY) ) - self.combobox_translator.grid(row=0, column=1, columnspan=2 ,padx=(0, 5), pady=5, sticky="nsew") - self.combobox_translator.configure(values=["DeepL"],) - self.combobox_translator.set(CHOICE_TRANSLATOR) + self.optionmenu_translator.grid(row=0, column=1, columnspan=2 ,padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_translator.set(CHOICE_TRANSLATOR) - # combobox language + # optionmenu language self.label_language = customtkinter.CTkLabel( self.tabview_config.tab("GUI"), - text="select language:", + text="Select Language:", fg_color="transparent", font=customtkinter.CTkFont(family=FONT_FAMILY) ) self.label_language.grid(row=1, column=0, columnspan=1, padx=5, pady=5, sticky="nsew") - self.combobox_language = customtkinter.CTkComboBox( + self.optionmenu_language = customtkinter.CTkOptionMenu( self.tabview_config.tab("GUI"), - command=self.combobox_language_callback, + command=self.optionmenu_language_callback, font=customtkinter.CTkFont(family=FONT_FAMILY) ) - self.combobox_language.grid(row=1, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") - self.combobox_language.configure( + self.optionmenu_language.grid(row=1, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_language.configure( values=[ "JA","BG","CS","DA","DE","EL","EN","EN-US","EN-GB","ES","ET","FI","FR","HU", "ID","IT","KO","LT","LV","NB","NL","PL","PT","PT-BR","PT-PT","RO","RU","SK", "SL","SV","TR","UK","ZH", ] ) - self.combobox_language.set(TARGET_LANG) + self.optionmenu_language.set(TARGET_LANG) # slider transparency self.label_transparency = customtkinter.CTkLabel( @@ -216,6 +228,55 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.slider_transparency.grid(row=2, column=1, columnspan=2, padx=5, pady=10, sticky="nsew") self.slider_transparency.set(TRANSPARENCY) + # optionmenu theme + self.label_appearance_theme = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="Appearance Theme:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_appearance_theme.grid(row=3, column=0, columnspan=1, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_appearance_theme = customtkinter.CTkOptionMenu( + self.tabview_config.tab("GUI"), + values=["Light", "Dark", "System"], + command=self.optionmenu_theme_callback + ) + self.optionmenu_appearance_theme.grid(row=3, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_appearance_theme.set(APPEARANCE_THEME) + + # optionmenu UI scaling + self.label_ui_scaling = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="UI Scaling:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_ui_scaling.grid(row=4, column=0, columnspan=1, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_ui_scaling = customtkinter.CTkOptionMenu( + self.tabview_config.tab("GUI"), + values=["80%", "90%", "100%", "110%", "120%"], + command=self.optionmenu_ui_scaling_callback + ) + self.optionmenu_ui_scaling.grid(row=4, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_ui_scaling.set(UI_SCALING) + + # optionmenu font family + self.label_font_family = customtkinter.CTkLabel( + self.tabview_config.tab("GUI"), + text="Font Family:", + fg_color="transparent", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) + self.label_font_family.grid(row=5, column=0, columnspan=1, padx=(0, 5), pady=5, sticky="nsew") + font_families = list(tk.font.families()) + self.optionmenu_font_family = customtkinter.CTkOptionMenu( + self.tabview_config.tab("GUI"), + values=font_families, + command=self.optionmenu_font_family_callback + ) + self.optionmenu_font_family.grid(row=5, column=1, columnspan=2, padx=(0, 5), pady=5, sticky="nsew") + self.optionmenu_font_family.set(FONT_FAMILY) + # entry ip address self.label_ip_address = customtkinter.CTkLabel( self.tabview_config.tab("Parameter"), @@ -343,7 +404,6 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): json.dump(config, fp, indent=4) TRANSLATOR = deepl.Translator(AUTH_KEY) - self.parent.textbox_message_log.configure(state='normal') self.parent.textbox_message_log.delete("0.0", "end") self.parent.textbox_message_log.configure(state='disabled') @@ -376,7 +436,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): json.dump(config, fp, indent=4) self.parent.wm_attributes("-alpha", TRANSPARENCY/100) - def combobox_translator_callback(self, choice): + def optionmenu_translator_callback(self, choice): global CHOICE_TRANSLATOR CHOICE_TRANSLATOR = choice with open(PATH_CONFIG, "r") as fp: @@ -385,7 +445,7 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): with open(PATH_CONFIG, "w") as fp: json.dump(config, fp, indent=4) - def combobox_language_callback(self, choice): + def optionmenu_language_callback(self, choice): global TARGET_LANG TARGET_LANG = choice with open(PATH_CONFIG, "r") as fp: @@ -394,13 +454,69 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): with open(PATH_CONFIG, "w") as fp: json.dump(config, fp, indent=4) + def optionmenu_theme_callback(self, choice): + global APPEARANCE_THEME + APPEARANCE_THEME = choice + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["APPEARANCE_THEME"] = APPEARANCE_THEME + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + customtkinter.set_appearance_mode(APPEARANCE_THEME) + + def optionmenu_ui_scaling_callback(self, choice): + global UI_SCALING + UI_SCALING = choice + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["UI_SCALING"] = UI_SCALING + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + new_scaling_float = int(UI_SCALING.replace("%", "")) / 100 + customtkinter.set_widget_scaling(new_scaling_float) + + def optionmenu_font_family_callback(self, choice): + global FONT_FAMILY + FONT_FAMILY = choice + with open(PATH_CONFIG, "r") as fp: + config = json.load(fp) + config["FONT_FAMILY"] = FONT_FAMILY + with open(PATH_CONFIG, "w") as fp: + json.dump(config, fp, indent=4) + + self.parent.checkbox_translation.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.parent.checkbox_foreground.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.parent.textbox_message_log.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.parent.entry_message_box.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.tabview_config._segmented_button.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_translator.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.optionmenu_translator.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_language.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.optionmenu_language.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_transparency.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_appearance_theme.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.optionmenu_appearance_theme.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_ui_scaling.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.optionmenu_ui_scaling.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_font_family.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.optionmenu_font_family.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_ip_address.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.entry_ip_address.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_port.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.entry_port.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_authkey.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.entry_authkey.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.label_message_format.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.entry_message_format.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + class App(customtkinter.CTk): - def __init__(self): - super().__init__() + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) self.iconbitmap(os.path.join(os.path.dirname(__file__), "img", "app.ico")) self.title("VRCT") - self.geometry(f"{400}x{120}") - self.minsize(400, 120) + self.geometry(f"{400}x{110}") + self.minsize(400, 110) self.grid_columnconfigure(1, weight=1) self.grid_rowconfigure(0, weight=1) @@ -410,36 +526,63 @@ class App(customtkinter.CTk): self.sidebar_frame.grid_rowconfigure(5, weight=1) # checkbox translation - self.checkbox_translation = customtkinter.CTkCheckBox(self.sidebar_frame, text="translation", onvalue=True, offvalue=False, - command=self.checkbox_translation_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.checkbox_translation = customtkinter.CTkCheckBox( + self.sidebar_frame, + text="translation", + onvalue=True, + offvalue=False, + command=self.checkbox_translation_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.checkbox_translation.grid(row=0, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # checkbox foreground - self.checkbox_foreground = customtkinter.CTkCheckBox(self.sidebar_frame, text="foreground", onvalue=True, offvalue=False, - command=self.checkbox_foreground_callback, - font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.checkbox_foreground = customtkinter.CTkCheckBox( + self.sidebar_frame, + text="foreground", + onvalue=True, + offvalue=False, + command=self.checkbox_foreground_callback, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.checkbox_foreground.grid(row=1, column=0, columnspan=2 ,padx=10, pady=(5, 5), sticky="we") # button information - self.button_information = customtkinter.CTkButton(self.sidebar_frame, text="", width=25, command=self.open_information, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "info-icon-white.png")))) - self.button_information.grid(row=5, column=0, padx=(10, 5), pady=(10, 10), sticky="wse") + self.button_information = customtkinter.CTkButton( + self.sidebar_frame, + text="", + width=25, + command=self.open_information, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "info-icon-white.png"))) + ) + self.button_information.grid(row=5, column=0, padx=(10, 5), pady=(5, 5), sticky="wse") self.information_window = None # button config - self.button_config = customtkinter.CTkButton(self.sidebar_frame, text="", width=25, command=self.open_config, - image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "config-icon-white.png")))) - self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(10, 10), sticky="wse") + self.button_config = customtkinter.CTkButton( + self.sidebar_frame, + text="", + width=25, + command=self.open_config, + image=customtkinter.CTkImage(Image.open(os.path.join(os.path.dirname(__file__), "img", "config-icon-white.png"))) + ) + self.button_config.grid(row=5, column=1, padx=(5, 10), pady=(5, 5), sticky="wse") self.config_window = None # create textbox message log - self.textbox_message_log = customtkinter.CTkTextbox(self, font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.textbox_message_log = customtkinter.CTkTextbox( + self, + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.textbox_message_log.grid(row=0, column=1, padx=(10, 10), pady=(10, 5), sticky="nsew") self.textbox_message_log.configure(state='disabled') # create entry message box - self.entry_message_box = customtkinter.CTkEntry(self, placeholder_text="message", font=customtkinter.CTkFont(family=FONT_FAMILY)) + self.entry_message_box = customtkinter.CTkEntry( + self, + placeholder_text="message", + font=customtkinter.CTkFont(family=FONT_FAMILY) + ) self.entry_message_box.grid(row=1, column=1, columnspan=2, padx=(10, 10), pady=(5, 10), sticky="nsew") # set default values From fb5c9dbb2e9f705c6d4db1af52fd52187fb14c55 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 3 Jun 2023 00:59:09 +0900 Subject: [PATCH 5/8] update information --- VRCT.py | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/VRCT.py b/VRCT.py index ef6674ae..014590ba 100644 --- a/VRCT.py +++ b/VRCT.py @@ -107,7 +107,8 @@ VRChatで使用されるChatBoxをOSC経由でメッセージを送信するツ # 使用方法 初期設定時 1. DeepLのAPIを使用するためにアカウント登録し、認証キーを取得する - 2. configボタンでconfigウィンドウを開きDeepL Auth Keyに認証キーを記載しcheckボタンを押す + 2. ギアアイコンのボタンでconfigウィンドウを開く + 3. ParameterタブのDeepL Auth Keyに認証キーを記載し、フロッピーアイコンのボタンを押す 3. configウィンドウを閉じる 通常使用時 @@ -119,13 +120,21 @@ VRChatで使用されるChatBoxをOSC経由でメッセージを送信するツ foreground チェックボックス: 最前面表示の有効無効 configウィンドウ - OSC IP address: 変更不要 - OSC port: 変更不要 - DeepL Auth key: DeepLの認証キーの設定 - Message Format: 送信するメッセージのデコレーションの設定 - [message]がメッセージボックスに記入したメッセージに置換される - [translation]が翻訳されたメッセージに置換される - 初期フォーマット:"[message]([translation])" + GUIタブ + Select translator: 翻訳APIの変更(今はDeepLのみ) + Select Language: 翻訳する言語を選択 + Transparency: ウィンドウの透過度の調整 + Appearance Theme: ウィンドウテーマを選択 + UI Scaling: UIサイズを調整 + Font Family: 表示フォントを選択 + Parameterタブ + OSC IP address: 変更不要 + OSC port: 変更不要 + DeepL Auth key: DeepLの認証キーの設定 + Message Format: 送信するメッセージのデコレーションの設定 + [message]がメッセージボックスに記入したメッセージに置換される + [translation]が翻訳されたメッセージに置換される + 初期フォーマット:"[message]([translation])" 設定の初期化 config.jsonを削除 @@ -142,6 +151,12 @@ https://twitter.com/misya_ai - 翻訳機能有効無効のチェックボックスを追加 - 最前面表示の有効無効のチェックボックスを追加 - いくつかのバグを修正 +[2023-06-03: v0.3b] +- 全体的にUIを刷新 +- 透過機能を追加 +- テーマのLight/Dark/Systemのモードの変更機能を追加 +- UIのスケール変更機能を追加 +- フォントの変更機能を追加 # 注意事項 再配布とかはやめてね From 2fad9abbab3817fc4ae5d6cd0274f1f067f720d5 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 3 Jun 2023 01:07:35 +0900 Subject: [PATCH 6/8] =?UTF-8?q?Auth=20key=E3=82=92=E5=85=A5=E5=8A=9B?= =?UTF-8?q?=E3=81=97=E3=81=AA=E3=81=8F=E3=81=A6=E3=82=82=E6=96=87=E5=AD=97?= =?UTF-8?q?=E5=85=A5=E5=8A=9B=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/VRCT.py b/VRCT.py index ef6674ae..addcfb1e 100644 --- a/VRCT.py +++ b/VRCT.py @@ -642,13 +642,10 @@ class App(customtkinter.CTk): self.attributes("-topmost", False) def entry_message_box_press_key_enter(self, event): - if TRANSLATOR is None: - pass - else: - message = self.entry_message_box.get() - + message = self.entry_message_box.get() + if len(message) > 0: # translate - if self.checkbox_translation.get() is True and len(message) > 0: + if (self.checkbox_translation.get() is True) and (TRANSLATOR is not None): result = TRANSLATOR.translate_text(message, target_lang=TARGET_LANG) chat_message = MESSAGE_FORMAT.replace("[message]", message).replace("[translation]", result.text) else: From 3e71bd392640e7325717f109c8b2fa843dc8f332 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 3 Jun 2023 01:28:40 +0900 Subject: [PATCH 7/8] =?UTF-8?q?=E6=9C=80=E5=89=8D=E9=9D=A2=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E3=81=AE=E3=83=90=E3=82=B0=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/VRCT.py b/VRCT.py index addcfb1e..64c01abf 100644 --- a/VRCT.py +++ b/VRCT.py @@ -599,6 +599,8 @@ class App(customtkinter.CTk): self.attributes("-topmost", False) self.entry_message_box.bind("", self.entry_message_box_press_key_enter) + self.entry_message_box.bind("", self.entry_message_box_press_key_any) + self.entry_message_box.bind("", self.entry_message_box_leave) if TRANSLATOR is None: # error update Auth key @@ -642,6 +644,9 @@ class App(customtkinter.CTk): self.attributes("-topmost", False) def entry_message_box_press_key_enter(self, event): + if ENABLE_FOREGROUND: + self.attributes("-topmost", True) + message = self.entry_message_box.get() if len(message) > 0: # translate @@ -668,6 +673,14 @@ class App(customtkinter.CTk): # delete message in entry message box self.entry_message_box.delete(0, customtkinter.END) + def entry_message_box_press_key_any(self, event): + if ENABLE_FOREGROUND: + self.attributes("-topmost", False) + + def entry_message_box_leave(self, event): + if ENABLE_FOREGROUND: + self.attributes("-topmost", True) + if __name__ == "__main__": app = App() app.mainloop() \ No newline at end of file From e72e9302b6941a152414c29bc063b69dafca0893 Mon Sep 17 00:00:00 2001 From: misyaguziya Date: Sat, 3 Jun 2023 01:34:00 +0900 Subject: [PATCH 8/8] =?UTF-8?q?information=5Fwindow=E3=81=8C=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E3=81=97=E3=81=AA=E3=81=84=E5=A0=B4=E5=90=88=E3=81=AE?= =?UTF-8?q?=E5=87=A6=E7=90=86=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCT.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/VRCT.py b/VRCT.py index b514ac90..793a4c02 100644 --- a/VRCT.py +++ b/VRCT.py @@ -503,7 +503,10 @@ class ToplevelWindowConfig(customtkinter.CTkToplevel): self.parent.checkbox_foreground.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) self.parent.textbox_message_log.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) self.parent.entry_message_box.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) - self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + try: + self.parent.information_window.textbox_information.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) + except: + pass self.tabview_config._segmented_button.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) self.label_translator.configure(font=customtkinter.CTkFont(family=FONT_FAMILY)) self.optionmenu_translator.configure(font=customtkinter.CTkFont(family=FONT_FAMILY))