[Refactor] Main Window: _printToTextbox. textboxへの出力関数のリファクタリング2
textbox widget指定を_printToTextbox関数内で行うように。
This commit is contained in:
@@ -1,7 +1,20 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from customtkinter import CTkFont
|
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_raw_data = datetime.now()
|
||||||
now = now_raw_data.strftime('%H:%M:%S')
|
now = now_raw_data.strftime('%H:%M:%S')
|
||||||
now_hm = now_raw_data.strftime('%H:%M')
|
now_hm = now_raw_data.strftime('%H:%M')
|
||||||
|
|||||||
@@ -126,26 +126,19 @@ class VRCT_GUI(CTk):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def printToTextbox(self, target_type, original_message=None, translated_message=None):
|
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(
|
_printToTextbox(
|
||||||
|
vrct_gui=self,
|
||||||
settings=self.settings.main,
|
settings=self.settings.main,
|
||||||
target_textbox=target_textbox,
|
target_type=target_type,
|
||||||
original_message=original_message,
|
original_message=original_message,
|
||||||
translated_message=translated_message,
|
translated_message=translated_message,
|
||||||
tags=target_type,
|
tags=target_type,
|
||||||
)
|
)
|
||||||
# To automatically print the same log to the textbox_all widget as well.
|
# To automatically print the same log to the textbox_all widget as well.
|
||||||
_printToTextbox(
|
_printToTextbox(
|
||||||
|
vrct_gui=self,
|
||||||
settings=self.settings.main,
|
settings=self.settings.main,
|
||||||
target_textbox=self.textbox_all,
|
target_type="ALL",
|
||||||
original_message=original_message,
|
original_message=original_message,
|
||||||
translated_message=translated_message,
|
translated_message=translated_message,
|
||||||
tags=target_type,
|
tags=target_type,
|
||||||
|
|||||||
Reference in New Issue
Block a user