Merge branch 'remove_textbox_tabs' into develop
This commit is contained in:
@@ -31,28 +31,30 @@ class _PrintToTextbox():
|
||||
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)
|
||||
|
||||
|
||||
def printToTextbox(self, target_type, original_message=None, translated_message=None, to_print_to_textbox_all:bool=True):
|
||||
self._printEachTextbox(
|
||||
target_textbox=self._getTargetTextboxWidget(target_type),
|
||||
print_type=target_type,
|
||||
original_message=original_message,
|
||||
translated_message=translated_message,
|
||||
)
|
||||
# [Deprecated] Print to textbox to only all-tab. sent received system tabs are deprecated.
|
||||
# self._printEachTextbox(
|
||||
# target_textbox=self._getTargetTextboxWidget(target_type),
|
||||
# print_type=target_type,
|
||||
# original_message=original_message,
|
||||
# translated_message=translated_message,
|
||||
# )
|
||||
|
||||
# To automatically print the same log to the textbox_all widget as well.
|
||||
if to_print_to_textbox_all is True:
|
||||
self._printEachTextbox(
|
||||
target_textbox=self._getTargetTextboxWidget("ALL"),
|
||||
print_type=target_type,
|
||||
original_message=original_message,
|
||||
translated_message=translated_message,
|
||||
)
|
||||
# if to_print_to_textbox_all is True:
|
||||
self._printEachTextbox(
|
||||
target_textbox=self._getTargetTextboxWidget("ALL"),
|
||||
print_type=target_type,
|
||||
original_message=original_message,
|
||||
translated_message=translated_message,
|
||||
)
|
||||
|
||||
def setTagsSettings(self, custom_font_size_scale:float=1.0):
|
||||
# Calculate Textbox's ui size by default size * textbox_ui_scale
|
||||
@@ -156,12 +158,12 @@ class _PrintToTextbox():
|
||||
match (target_type):
|
||||
case "ALL":
|
||||
target_textbox = self.vrct_gui.textbox_all
|
||||
case "SYSTEM":
|
||||
target_textbox = self.vrct_gui.textbox_system
|
||||
case "SENT":
|
||||
target_textbox = self.vrct_gui.textbox_sent
|
||||
case "RECEIVED":
|
||||
target_textbox = self.vrct_gui.textbox_received
|
||||
# case "SYSTEM":
|
||||
# target_textbox = self.vrct_gui.textbox_system
|
||||
# case "SENT":
|
||||
# target_textbox = self.vrct_gui.textbox_sent
|
||||
# case "RECEIVED":
|
||||
# target_textbox = self.vrct_gui.textbox_received
|
||||
case (_):
|
||||
raise ValueError(f"No matching case for target_type: {target_type}")
|
||||
|
||||
|
||||
@@ -5,53 +5,53 @@ from ...ui_utils import bindEnterAndLeaveColor, bindButtonPressColor, bindButton
|
||||
|
||||
def createTextbox(settings, main_window, view_variable):
|
||||
|
||||
def switchTextbox(target_textbox_attr_name):
|
||||
main_window.current_active_textbox.grid_remove()
|
||||
main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name)
|
||||
main_window.current_active_textbox.grid()
|
||||
# def switchTextbox(target_textbox_attr_name):
|
||||
# main_window.current_active_textbox.grid_remove()
|
||||
# main_window.current_active_textbox = getattr(main_window, target_textbox_attr_name)
|
||||
# main_window.current_active_textbox.grid()
|
||||
|
||||
def switchToTextboxAll(e):
|
||||
target_active_widget = getattr(main_window, "textbox_tab_all")
|
||||
switchTextboxTabFunction(target_active_widget)
|
||||
switchTextbox("textbox_all")
|
||||
# def switchToTextboxAll(e):
|
||||
# target_active_widget = getattr(main_window, "textbox_tab_all")
|
||||
# switchTextboxTabFunction(target_active_widget)
|
||||
# switchTextbox("textbox_all")
|
||||
|
||||
def switchToTextboxSent(e):
|
||||
target_active_widget = getattr(main_window, "textbox_tab_sent")
|
||||
switchTextboxTabFunction(target_active_widget)
|
||||
switchTextbox("textbox_sent")
|
||||
# def switchToTextboxSent(e):
|
||||
# target_active_widget = getattr(main_window, "textbox_tab_sent")
|
||||
# switchTextboxTabFunction(target_active_widget)
|
||||
# switchTextbox("textbox_sent")
|
||||
|
||||
def switchToTextboxReceived(e):
|
||||
target_active_widget = getattr(main_window, "textbox_tab_received")
|
||||
switchTextboxTabFunction(target_active_widget)
|
||||
switchTextbox("textbox_received")
|
||||
# def switchToTextboxReceived(e):
|
||||
# target_active_widget = getattr(main_window, "textbox_tab_received")
|
||||
# switchTextboxTabFunction(target_active_widget)
|
||||
# switchTextbox("textbox_received")
|
||||
|
||||
def switchToTextboxSystem(e):
|
||||
target_active_widget = getattr(main_window, "textbox_tab_system")
|
||||
switchTextboxTabFunction(target_active_widget)
|
||||
switchTextbox("textbox_system")
|
||||
# def switchToTextboxSystem(e):
|
||||
# target_active_widget = getattr(main_window, "textbox_tab_system")
|
||||
# switchTextboxTabFunction(target_active_widget)
|
||||
# switchTextbox("textbox_system")
|
||||
|
||||
|
||||
def switchTextboxTabFunction(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)
|
||||
main_window.current_active_textbox_tab = target_active_widget
|
||||
# def switchTextboxTabFunction(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)
|
||||
# main_window.current_active_textbox_tab = target_active_widget
|
||||
|
||||
def switchActiveAndPassiveTextboxTabsColor(target_active_widget):
|
||||
textbox_tabs = [
|
||||
getattr(main_window, "textbox_tab_all"),
|
||||
getattr(main_window, "textbox_tab_sent"),
|
||||
getattr(main_window, "textbox_tab_received"),
|
||||
getattr(main_window, "textbox_tab_system")
|
||||
]
|
||||
# def switchActiveAndPassiveTextboxTabsColor(target_active_widget):
|
||||
# textbox_tabs = [
|
||||
# getattr(main_window, "textbox_tab_all"),
|
||||
# getattr(main_window, "textbox_tab_sent"),
|
||||
# getattr(main_window, "textbox_tab_received"),
|
||||
# getattr(main_window, "textbox_tab_system")
|
||||
# ]
|
||||
|
||||
switchTabsColor(
|
||||
target_widget=target_active_widget,
|
||||
tab_buttons=textbox_tabs,
|
||||
active_bg_color=settings.ctm.TEXTBOX_BG_COLOR,
|
||||
active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR,
|
||||
passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
|
||||
passive_text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR
|
||||
)
|
||||
# switchTabsColor(
|
||||
# target_widget=target_active_widget,
|
||||
# tab_buttons=textbox_tabs,
|
||||
# active_bg_color=settings.ctm.TEXTBOX_BG_COLOR,
|
||||
# active_text_color=settings.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR,
|
||||
# passive_bg_color=settings.ctm.TEXTBOX_TAB_BG_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_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.place(relx=0.07, rely=1.15, anchor="sw")
|
||||
# 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.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_tab_attr_name": "textbox_tab_all",
|
||||
"command": switchToTextboxAll,
|
||||
"textbox_attr_name": "textbox_all",
|
||||
"textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL
|
||||
},
|
||||
{
|
||||
"textbox_tab_attr_name": "textbox_tab_sent",
|
||||
"command": switchToTextboxSent,
|
||||
"textbox_attr_name": "textbox_sent",
|
||||
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT
|
||||
},
|
||||
{
|
||||
"textbox_tab_attr_name": "textbox_tab_received",
|
||||
"command": switchToTextboxReceived,
|
||||
"textbox_attr_name": "textbox_received",
|
||||
"textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED
|
||||
},
|
||||
{
|
||||
"textbox_tab_attr_name": "textbox_tab_system",
|
||||
"command": switchToTextboxSystem,
|
||||
"textbox_attr_name": "textbox_system",
|
||||
"textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM
|
||||
},
|
||||
]
|
||||
# textbox_settings = [
|
||||
# {
|
||||
# "textbox_tab_attr_name": "textbox_tab_all",
|
||||
# "command": switchToTextboxAll,
|
||||
# "textbox_attr_name": "textbox_all",
|
||||
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_ALL
|
||||
# },
|
||||
# {
|
||||
# "textbox_tab_attr_name": "textbox_tab_sent",
|
||||
# "command": switchToTextboxSent,
|
||||
# "textbox_attr_name": "textbox_sent",
|
||||
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_SENT
|
||||
# },
|
||||
# {
|
||||
# "textbox_tab_attr_name": "textbox_tab_received",
|
||||
# "command": switchToTextboxReceived,
|
||||
# "textbox_attr_name": "textbox_received",
|
||||
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_RECEIVED
|
||||
# },
|
||||
# {
|
||||
# "textbox_tab_attr_name": "textbox_tab_system",
|
||||
# "command": switchToTextboxSystem,
|
||||
# "textbox_attr_name": "textbox_system",
|
||||
# "textvariable": view_variable.VAR_LABEL_TEXTBOX_SYSTEM
|
||||
# },
|
||||
# ]
|
||||
|
||||
|
||||
column=0
|
||||
for textbox_setting in textbox_settings:
|
||||
setattr(main_window, textbox_setting["textbox_tab_attr_name"],
|
||||
CTkFrame(
|
||||
main_window.textbox_switch_tabs_container,
|
||||
corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS,
|
||||
fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
|
||||
cursor="hand2",
|
||||
width=0,
|
||||
height=0
|
||||
)
|
||||
)
|
||||
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")
|
||||
# column=0
|
||||
# for textbox_setting in textbox_settings:
|
||||
# setattr(main_window, textbox_setting["textbox_tab_attr_name"],
|
||||
# CTkFrame(
|
||||
# main_window.textbox_switch_tabs_container,
|
||||
# corner_radius=settings.uism.TEXTBOX_TAB_CORNER_RADIUS,
|
||||
# fg_color=settings.ctm.TEXTBOX_TAB_BG_PASSIVE_COLOR,
|
||||
# cursor="hand2",
|
||||
# width=0,
|
||||
# height=0
|
||||
# )
|
||||
# )
|
||||
# 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_columnconfigure((0,2), weight=1)
|
||||
setattr(main_window, "label_widget", CTkLabel(
|
||||
target_widget,
|
||||
textvariable=textbox_setting["textvariable"],
|
||||
corner_radius=0,
|
||||
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"),
|
||||
height=0,
|
||||
width=0,
|
||||
anchor="center",
|
||||
text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR,
|
||||
))
|
||||
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)
|
||||
# target_widget.grid_columnconfigure((0,2), weight=1)
|
||||
# setattr(main_window, "label_widget", CTkLabel(
|
||||
# target_widget,
|
||||
# textvariable=textbox_setting["textvariable"],
|
||||
# corner_radius=0,
|
||||
# font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.TEXTBOX_TAB_FONT_SIZE, weight="normal"),
|
||||
# height=0,
|
||||
# width=0,
|
||||
# anchor="center",
|
||||
# text_color=settings.ctm.TEXTBOX_TAB_TEXT_PASSIVE_COLOR,
|
||||
# ))
|
||||
# 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)
|
||||
|
||||
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)
|
||||
# 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)
|
||||
|
||||
target_widget.passive_function = textbox_setting["command"]
|
||||
bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"])
|
||||
# target_widget.passive_function = textbox_setting["command"]
|
||||
# bindButtonReleaseFunction([target_widget, label_widget], textbox_setting["command"])
|
||||
|
||||
|
||||
|
||||
setattr(main_window, textbox_setting["textbox_attr_name"], CTkTextbox(
|
||||
main_window.main_textbox_container,
|
||||
corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS,
|
||||
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.
|
||||
wrap="word",
|
||||
height=0,
|
||||
))
|
||||
textbox_widget = getattr(main_window, textbox_setting["textbox_attr_name"])
|
||||
textbox_widget.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew")
|
||||
textbox_widget.grid_remove()
|
||||
textbox_widget.configure(state="disabled")
|
||||
main_window.textbox_all = CTkTextbox(
|
||||
main_window.main_textbox_container,
|
||||
corner_radius=settings.uism.TEXTBOX_CORNER_RADIUS,
|
||||
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.
|
||||
wrap="word",
|
||||
height=0,
|
||||
)
|
||||
# main_window.textbox_all = getattr(main_window, textbox_setting["textbox_attr_name"])
|
||||
main_window.textbox_all.grid(row=0, column=0, padx=settings.uism.TEXTBOX_PADX, pady=0, sticky="nsew")
|
||||
main_window.textbox_all.grid_remove()
|
||||
main_window.textbox_all.configure(state="disabled")
|
||||
|
||||
column+=1
|
||||
# column+=1
|
||||
|
||||
# Set default active textbox tab
|
||||
main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all")
|
||||
setDefaultActiveTab(
|
||||
active_tab_widget=main_window.current_active_textbox_tab,
|
||||
active_bg_color=settings.ctm.TEXTBOX_TAB_BG_ACTIVE_COLOR,
|
||||
active_text_color=settings.ctm.TEXTBOX_TAB_TEXT_ACTIVE_COLOR
|
||||
)
|
||||
# main_window.current_active_textbox_tab = getattr(main_window, "textbox_tab_all")
|
||||
# setDefaultActiveTab(
|
||||
# active_tab_widget=main_window.current_active_textbox_tab,
|
||||
# active_bg_color=settings.ctm.TEXTBOX_TAB_BG_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.grid()
|
||||
# main_window.current_active_textbox = getattr(main_window, "textbox_all")
|
||||
# main_window.current_active_textbox.grid()
|
||||
main_window.textbox_all.grid()
|
||||
|
||||
Reference in New Issue
Block a user