From f27e4985cddcf435da9ee7c79be0b69621a5955b Mon Sep 17 00:00:00 2001 From: Sakamoto Shiina <68018796+ShiinaSakamoto@users.noreply.github.com> Date: Thu, 14 Sep 2023 05:13:47 +0900 Subject: [PATCH] =?UTF-8?q?[Refactor]=20Main=20Window:=20=5FprintToTextbox?= =?UTF-8?q?.=20textbox=E3=81=B8=E3=81=AE=E5=87=BA=E5=8A=9B=E9=96=A2?= =?UTF-8?q?=E6=95=B0=E3=81=AE=E3=83=AA=E3=83=95=E3=82=A1=E3=82=AF=E3=82=BF?= =?UTF-8?q?=E3=83=AA=E3=83=B3=E3=82=B02=20textbox=20widget=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=82=92=5FprintToTextbox=E9=96=A2=E6=95=B0=E5=86=85?= =?UTF-8?q?=E3=81=A7=E8=A1=8C=E3=81=86=E3=82=88=E3=81=86=E3=81=AB=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vrct_gui/_printToTextbox.py | 15 ++++++++++++++- vrct_gui/vrct_gui.py | 15 ++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/vrct_gui/_printToTextbox.py b/vrct_gui/_printToTextbox.py index 9becc64d..41258793 100644 --- a/vrct_gui/_printToTextbox.py +++ b/vrct_gui/_printToTextbox.py @@ -1,7 +1,20 @@ from datetime import datetime from customtkinter import CTkFont -def _printToTextbox(settings, target_textbox, original_message=None, translated_message=None, tags=None): +def _printToTextbox(vrct_gui, settings, target_type, original_message=None, translated_message=None, tags=None): + match (target_type): + case "ALL": + target_textbox = vrct_gui.textbox_all + case "INFO": + target_textbox = vrct_gui.textbox_system + case "SEND": + target_textbox = vrct_gui.textbox_sent + case "RECEIVE": + target_textbox = vrct_gui.textbox_received + case (_): + raise ValueError(f"No matching case for target_type: {target_type}") + + now_raw_data = datetime.now() now = now_raw_data.strftime('%H:%M:%S') now_hm = now_raw_data.strftime('%H:%M') diff --git a/vrct_gui/vrct_gui.py b/vrct_gui/vrct_gui.py index f525ff4a..f181115f 100644 --- a/vrct_gui/vrct_gui.py +++ b/vrct_gui/vrct_gui.py @@ -126,26 +126,19 @@ class VRCT_GUI(CTk): ) def printToTextbox(self, target_type, original_message=None, translated_message=None): - match (target_type): - case "INFO": - target_textbox = self.textbox_system - case "SEND": - target_textbox = self.textbox_sent - case "RECEIVE": - target_textbox = self.textbox_received - case (_): - raise ValueError(f"No matching case for target_type: {target_type}") _printToTextbox( + vrct_gui=self, settings=self.settings.main, - target_textbox=target_textbox, + target_type=target_type, original_message=original_message, translated_message=translated_message, tags=target_type, ) # To automatically print the same log to the textbox_all widget as well. _printToTextbox( + vrct_gui=self, settings=self.settings.main, - target_textbox=self.textbox_all, + target_type="ALL", original_message=original_message, translated_message=translated_message, tags=target_type,