Merge branch 'remove_textbox_tabs' into develop

This commit is contained in:
Sakamoto Shiina
2024-05-08 17:17:24 +09:00
2 changed files with 143 additions and 140 deletions

View File

@@ -31,28 +31,30 @@ class _PrintToTextbox():
self.textbox_font_size__main_text_font = None self.textbox_font_size__main_text_font = None
self.all_textbox_widgets = [self.vrct_gui.textbox_all, self.vrct_gui.textbox_system, self.vrct_gui.textbox_sent, self.vrct_gui.textbox_received] # self.all_textbox_widgets = [self.vrct_gui.textbox_all, self.vrct_gui.textbox_system, self.vrct_gui.textbox_sent, self.vrct_gui.textbox_received]
self.all_textbox_widgets = [self.vrct_gui.textbox_all]
self.setTagsSettings(self.init_scaling) self.setTagsSettings(self.init_scaling)
def printToTextbox(self, target_type, original_message=None, translated_message=None, to_print_to_textbox_all:bool=True): def printToTextbox(self, target_type, original_message=None, translated_message=None, to_print_to_textbox_all:bool=True):
self._printEachTextbox( # [Deprecated] Print to textbox to only all-tab. sent received system tabs are deprecated.
target_textbox=self._getTargetTextboxWidget(target_type), # self._printEachTextbox(
print_type=target_type, # target_textbox=self._getTargetTextboxWidget(target_type),
original_message=original_message, # print_type=target_type,
translated_message=translated_message, # original_message=original_message,
) # translated_message=translated_message,
# )
# 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.
if to_print_to_textbox_all is True: # if to_print_to_textbox_all is True:
self._printEachTextbox( self._printEachTextbox(
target_textbox=self._getTargetTextboxWidget("ALL"), target_textbox=self._getTargetTextboxWidget("ALL"),
print_type=target_type, print_type=target_type,
original_message=original_message, original_message=original_message,
translated_message=translated_message, translated_message=translated_message,
) )
def setTagsSettings(self, custom_font_size_scale:float=1.0): def setTagsSettings(self, custom_font_size_scale:float=1.0):
# Calculate Textbox's ui size by default size * textbox_ui_scale # Calculate Textbox's ui size by default size * textbox_ui_scale
@@ -156,12 +158,12 @@ class _PrintToTextbox():
match (target_type): match (target_type):
case "ALL": case "ALL":
target_textbox = self.vrct_gui.textbox_all target_textbox = self.vrct_gui.textbox_all
case "SYSTEM": # case "SYSTEM":
target_textbox = self.vrct_gui.textbox_system # target_textbox = self.vrct_gui.textbox_system
case "SENT": # case "SENT":
target_textbox = self.vrct_gui.textbox_sent # target_textbox = self.vrct_gui.textbox_sent
case "RECEIVED": # case "RECEIVED":
target_textbox = self.vrct_gui.textbox_received # target_textbox = self.vrct_gui.textbox_received
case (_): case (_):
raise ValueError(f"No matching case for target_type: {target_type}") raise ValueError(f"No matching case for target_type: {target_type}")

View File

@@ -5,53 +5,53 @@ from ...ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButton
def createTextbox(settings, main_window, view_variable): def createTextbox(settings, main_window, view_variable):
def switchTextbox(target_textbox_attr_name): # def switchTextbox(target_textbox_attr_name):
main_window.current_active_textbox.grid_remove() # main_window.current_active_textbox.grid_remove()
main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name) # main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name)
main_window.current_active_textbox.grid() # main_window.current_active_textbox.grid()
def switchToTextboxAll(e): # def switchToTextboxAll(e):
target_active_widget = getattr(main_window, "textbox_tab_all") # target_active_widget = getattr(main_window, "textbox_tab_all")
switchTextboxTabFunction(target_active_widget) # switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_all") # switchTextbox("textbox_all")
def switchToTextboxSent(e): # def switchToTextboxSent(e):
target_active_widget = getattr(main_window, "textbox_tab_sent") # target_active_widget = getattr(main_window, "textbox_tab_sent")
switchTextboxTabFunction(target_active_widget) # switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_sent") # switchTextbox("textbox_sent")
def switchToTextboxReceived(e): # def switchToTextboxReceived(e):
target_active_widget = getattr(main_window, "textbox_tab_received") # target_active_widget = getattr(main_window, "textbox_tab_received")
switchTextboxTabFunction(target_active_widget) # switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_received") # switchTextbox("textbox_received")
def switchToTextboxSystem(e): # def switchToTextboxSystem(e):
target_active_widget = getattr(main_window, "textbox_tab_system") # target_active_widget = getattr(main_window, "textbox_tab_system")
switchTextboxTabFunction(target_active_widget) # switchTextboxTabFunction(target_active_widget)
switchTextbox("textbox_system") # switchTextbox("textbox_system")
def switchTextboxTabFunction(target_active_widget): # def switchTextboxTabFunction(target_active_widget):
switchActiveAndPassiveTextboxTabsColor(target_active_widget) # switchActiveAndPassiveTextboxTabsColor(target_active_widget)
switchActiveTabAndPassiveTab(target_active_widget, main_window.current_active_textbox_tab, main_window.current_active_textbox_tab.passive_function, settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR) # switchActiveTabAndPassiveTab(target_active_widget, main_window.current_active_textbox_tab, main_window.current_active_textbox_tab.passive_function, settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
main_window.current_active_textbox_tab = target_active_widget # main_window.current_active_textbox_tab = target_active_widget
def switchActiveAndPassiveTextboxTabsColor(target_active_widget): # def switchActiveAndPassiveTextboxTabsColor(target_active_widget):
textbox_tabs = [ # textbox_tabs = [
getattr(main_window, "textbox_tab_all"), # getattr(main_window, "textbox_tab_all"),
getattr(main_window, "textbox_tab_sent"), # getattr(main_window, "textbox_tab_sent"),
getattr(main_window, "textbox_tab_received"), # getattr(main_window, "textbox_tab_received"),
getattr(main_window, "textbox_tab_system") # getattr(main_window, "textbox_tab_system")
] # ]
switchTabsColor( # switchTabsColor(
target_widget=target_active_widget, # target_widget=target_active_widget,
tab_buttons=textbox_tabs, # tab_buttons=textbox_tabs,
active_bg_color=settings.ctm.TEXTBOX_BG_COLOR, # active_bg_color=settings.ctm.TEXTBOX_BG_COLOR,
active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR, # active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR,
passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR, # passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
passive_text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR # passive_text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR
) # )
@@ -64,100 +64,101 @@ def createTextbox(settings, main_window, view_variable):
main_window.main_textbox_container.grid_columnconfigure(0,weight=1) main_window.main_textbox_container.grid_columnconfigure(0,weight=1)
main_window.main_textbox_container.grid_rowconfigure(0,weight=1) main_window.main_textbox_container.grid_rowconfigure(0,weight=1)
main_window.textbox_switch_tabs_container = CTkFrame(main_window.main_topbar_center_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0) # main_window.textbox_switch_tabs_container = CTkFrame(main_window.main_topbar_center_container, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
main_window.textbox_switch_tabs_container.place(relx=0.07, rely=1.15, anchor="sw") # main_window.textbox_switch_tabs_container.place(relx=0.07, rely=1.15, anchor="sw")
main_window.textbox_switch_tabs_container.grid_columnconfigure((0,1,2,3), weight=1, uniform="textbox_tabs") # main_window.textbox_switch_tabs_container.grid_columnconfigure((0,1,2,3), weight=1, uniform="textbox_tabs")
textbox_settings = [ # textbox_settings = [
{ # {
"textbox_tab_attr_name": "textbox_tab_all", # "textbox_tab_attr_name": "textbox_tab_all",
"command": switchToTextboxAll, # "command": switchToTextboxAll,
"textbox_attr_name": "textbox_all", # "textbox_attr_name": "textbox_all",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL # "textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL
}, # },
{ # {
"textbox_tab_attr_name": "textbox_tab_sent", # "textbox_tab_attr_name": "textbox_tab_sent",
"command": switchToTextboxSent, # "command": switchToTextboxSent,
"textbox_attr_name": "textbox_sent", # "textbox_attr_name": "textbox_sent",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT # "textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT
}, # },
{ # {
"textbox_tab_attr_name": "textbox_tab_received", # "textbox_tab_attr_name": "textbox_tab_received",
"command": switchToTextboxReceived, # "command": switchToTextboxReceived,
"textbox_attr_name": "textbox_received", # "textbox_attr_name": "textbox_received",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED # "textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED
}, # },
{ # {
"textbox_tab_attr_name": "textbox_tab_system", # "textbox_tab_attr_name": "textbox_tab_system",
"command": switchToTextboxSystem, # "command": switchToTextboxSystem,
"textbox_attr_name": "textbox_system", # "textbox_attr_name": "textbox_system",
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM # "textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM
}, # },
] # ]
column=0 # column=0
for textbox_setting in textbox_settings: # for textbox_setting in textbox_settings:
setattr(main_window, textbox_setting["textbox_tab_attr_name"], # setattr(main_window, textbox_setting["textbox_tab_attr_name"],
CTkFrame( # CTkFrame(
main_window.textbox_switch_tabs_container, # main_window.textbox_switch_tabs_container,
corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS, # corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS,
fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR, # fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
cursor="hand2", # cursor="hand2",
width=0, # width=0,
height=0 # height=0
) # )
) # )
target_widget = getattr(main_window, textbox_setting["textbox_tab_attr_name"]) # target_widget = getattr(main_window, textbox_setting["textbox_tab_attr_name"])
target_widget.grid(row=0, column=column, pady=0, padx=(0,2), sticky="ew") # target_widget.grid(row=0, column=column, pady=0, padx=(0,2), sticky="ew")
target_widget.grid_columnconfigure((0,2), weight=1) # target_widget.grid_columnconfigure((0,2), weight=1)
setattr(main_window, "label_widget", CTkLabel( # setattr(main_window, "label_widget", CTkLabel(
target_widget, # target_widget,
textvariable=textbox_setting["textvariable"], # textvariable=textbox_setting["textvariable"],
corner_radius=0, # corner_radius=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"), # font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"),
height=0, # height=0,
width=0, # width=0,
anchor="center", # anchor="center",
text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR, # text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR,
)) # ))
label_widget = getattr(main_window, "label_widget") # label_widget = getattr(main_window, "label_widget")
label_widget.grid(row=0, column=1, pady=settings.uism.TEXTBOX_TAB_PADY, padx=settings.uism.TEXTBOX_TAB_PADX) # label_widget.grid(row=0, column=1, pady=settings.uism.TEXTBOX_TAB_PADY, padx=settings.uism.TEXTBOX_TAB_PADX)
bindEnterAndLeaveColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR) # bindEnterAndLeaveColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_HOVERED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
bindButtonPressColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR) # bindButtonPressColor([target_widget, label_widget], settings.ctm.TEXTBOX_TAB_BG_CLICKED_COLOR, settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR)
target_widget.passive_function = textbox_setting["command"] # target_widget.passive_function = textbox_setting["command"]
bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"]) # bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"])
setattr(main_window, textbox_setting["textbox_attr_name"], CTkTextbox( main_window.textbox_all = CTkTextbox(
main_window.main_textbox_container, main_window.main_textbox_container,
corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS, corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS,
fg_color=settings.ctm.TEXTBOX_BG_COLOR, fg_color=settings.ctm.TEXTBOX_BG_COLOR,
text_color="lime", # Textbox's text_color is set when printing. so this is for prevent from non-setting text_color like the gloves used in food factories are blue. text_color="lime", # Textbox's text_color is set when printing. so this is for prevent from non-setting text_color like the gloves used in food factories are blue.
wrap="word", wrap="word",
height=0, height=0,
)) )
textbox_widget = getattr(main_window, textbox_setting["textbox_attr_name"]) # main_window.textbox_all = getattr(main_window, textbox_setting["textbox_attr_name"])
textbox_widget.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew") main_window.textbox_all.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew")
textbox_widget.grid_remove() main_window.textbox_all.grid_remove()
textbox_widget.configure(state="disabled") main_window.textbox_all.configure(state="disabled")
column+=1 # column+=1
# Set default active textbox tab # Set default active textbox tab
main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all") # main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all")
setDefaultActiveTab( # setDefaultActiveTab(
active_tab_widget=main_window.current_active_textbox_tab, # active_tab_widget=main_window.current_active_textbox_tab,
active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR, # active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR,
active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR # active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR
) # )
main_window.current_active_textbox = getattr(main_window, "textbox_all") # main_window.current_active_textbox = getattr(main_window, "textbox_all")
main_window.current_active_textbox.grid() # main_window.current_active_textbox.grid()
main_window.textbox_all.grid()