Merge branch 'config_window' into UI_2.0
This commit is contained in:
14
config.py
14
config.py
@@ -442,6 +442,17 @@ class Config:
|
||||
self._SELECTED_TAB_TARGET_LANGUAGES = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
# Config Window
|
||||
@property
|
||||
def IS_CONFIG_WINDOW_COMPACT_MODE(self):
|
||||
return self._IS_CONFIG_WINDOW_COMPACT_MODE
|
||||
|
||||
@IS_CONFIG_WINDOW_COMPACT_MODE.setter
|
||||
def IS_CONFIG_WINDOW_COMPACT_MODE(self, value):
|
||||
if type(value) is bool:
|
||||
self._IS_CONFIG_WINDOW_COMPACT_MODE = value
|
||||
saveJson(self.PATH_CONFIG, inspect.currentframe().f_code.co_name, value)
|
||||
|
||||
def init_config(self):
|
||||
self._VERSION = "1.3.2"
|
||||
self._PATH_CONFIG = "./config.json"
|
||||
@@ -505,6 +516,9 @@ class Config:
|
||||
"3":"English\n(United States)",
|
||||
}
|
||||
|
||||
# Config Window
|
||||
self._IS_CONFIG_WINDOW_COMPACT_MODE = False
|
||||
|
||||
def load_config(self):
|
||||
if os_path.isfile(self.PATH_CONFIG) is not False:
|
||||
with open(self.PATH_CONFIG, 'r') as fp:
|
||||
|
||||
15
main.py
15
main.py
@@ -211,6 +211,16 @@ def callbackToggleForeground():
|
||||
view.printToTextbox_disableForeground()
|
||||
view.foregroundOff()
|
||||
|
||||
|
||||
# Config Window
|
||||
def callbackEnableConfigWindowCompactMode():
|
||||
config.IS_CONFIG_WINDOW_COMPACT_MODE = True
|
||||
view.reloadConfigWindowSettingBoxContainer()
|
||||
|
||||
def callbackDisableConfigWindowCompactMode():
|
||||
config.IS_CONFIG_WINDOW_COMPACT_MODE = False
|
||||
view.reloadConfigWindowSettingBoxContainer()
|
||||
|
||||
# create GUI
|
||||
view.createGUI()
|
||||
|
||||
@@ -257,6 +267,11 @@ view.initializer(
|
||||
# },
|
||||
entry_message_box_bind_Return=messageBoxPressKeyEnter,
|
||||
entry_message_box_bind_Any_KeyPress=messageBoxPressKeyAny,
|
||||
|
||||
config_window={
|
||||
"callback_disable_config_window_compact_mode": callbackEnableConfigWindowCompactMode,
|
||||
"callback_enable_config_window_compact_mode": callbackDisableConfigWindowCompactMode,
|
||||
},
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
24
view.py
24
view.py
@@ -1,3 +1,5 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from customtkinter import StringVar, END as CTK_END
|
||||
from vrct_gui import vrct_gui
|
||||
|
||||
@@ -5,10 +7,15 @@ from config import config
|
||||
|
||||
class View():
|
||||
def __init__(self):
|
||||
self.settings = SimpleNamespace()
|
||||
self.settings.config_window = SimpleNamespace()
|
||||
self.settings.config_window = SimpleNamespace(
|
||||
is_config_window_compact_mode=config.IS_CONFIG_WINDOW_COMPACT_MODE
|
||||
)
|
||||
pass
|
||||
|
||||
|
||||
def initializer(self, sidebar_features, language_presets, entry_message_box, entry_message_box_bind_Return, entry_message_box_bind_Any_KeyPress):
|
||||
def initializer(self, sidebar_features, language_presets, entry_message_box, entry_message_box_bind_Return, entry_message_box_bind_Any_KeyPress, config_window):
|
||||
|
||||
vrct_gui.CALLBACK_TOGGLE_TRANSLATION = sidebar_features["callback_toggle_translation"]
|
||||
vrct_gui.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = sidebar_features["callback_toggle_transcription_send"]
|
||||
@@ -39,6 +46,13 @@ class View():
|
||||
entry_message_box.bind("<FocusOut>", self._foregroundOnForcefully)
|
||||
|
||||
|
||||
vrct_gui.config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE = config_window["callback_disable_config_window_compact_mode"]
|
||||
vrct_gui.config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE = config_window["callback_enable_config_window_compact_mode"]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def setMainWindowAllWidgetsStatusToNormal(self):
|
||||
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
|
||||
@@ -143,9 +157,15 @@ class View():
|
||||
|
||||
|
||||
def createGUI(self):
|
||||
vrct_gui.createGUI()
|
||||
vrct_gui.createGUI(settings=self.settings)
|
||||
|
||||
def startMainLoop(self):
|
||||
vrct_gui.startMainLoop()
|
||||
|
||||
|
||||
# Config Window
|
||||
def reloadConfigWindowSettingBoxContainer(self):
|
||||
vrct_gui.config_window.settings.IS_CONFIG_WINDOW_COMPACT_MODE = config.IS_CONFIG_WINDOW_COMPACT_MODE
|
||||
vrct_gui.config_window.reloadConfigWindowSettingBoxContainer()
|
||||
|
||||
view = View()
|
||||
@@ -1,9 +1,8 @@
|
||||
from .widgets import createConfigWindowTitle, createSettingBoxTitle, createSideMenuAndSettingsBoxContainers
|
||||
from .widgets import createConfigWindowTitle, createSideMenuAndSettingsBoxContainers, createSettingBoxTopBar
|
||||
|
||||
|
||||
from customtkinter import CTkToplevel
|
||||
|
||||
from config import config
|
||||
|
||||
class ConfigWindow(CTkToplevel):
|
||||
def __init__(self, vrct_gui, settings):
|
||||
super().__init__()
|
||||
@@ -18,12 +17,20 @@ class ConfigWindow(CTkToplevel):
|
||||
self.configure(fg_color="#ff7f50")
|
||||
self.protocol("WM_DELETE_WINDOW", vrct_gui.closeConfigWindow)
|
||||
|
||||
self.settings = settings
|
||||
|
||||
|
||||
|
||||
createConfigWindowTitle(config_window=self, settings=settings)
|
||||
|
||||
createSettingBoxTitle(config_window=self, settings=settings)
|
||||
createSettingBoxTopBar(config_window=self, settings=settings)
|
||||
|
||||
|
||||
createSideMenuAndSettingsBoxContainers(config_window=self, settings=settings)
|
||||
|
||||
|
||||
|
||||
|
||||
def reloadConfigWindowSettingBoxContainer(self):
|
||||
self.main_bg_container.destroy()
|
||||
createSideMenuAndSettingsBoxContainers(config_window=self, settings=self.settings)
|
||||
@@ -1,4 +1,4 @@
|
||||
from .createConfigWindowTitle import createConfigWindowTitle
|
||||
from .createSettingBoxTitle import createSettingBoxTitle
|
||||
from .createSettingBoxTopBar import createSettingBoxTopBar
|
||||
|
||||
from .createSideMenuAndSettingsBoxContainers import createSideMenuAndSettingsBoxContainers
|
||||
@@ -0,0 +1 @@
|
||||
from .createSettingBoxTopBar import createSettingBoxTopBar
|
||||
@@ -0,0 +1,67 @@
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel, CTkSwitch
|
||||
|
||||
def _createSettingBoxCompactModeButton(parent_widget, config_window, settings):
|
||||
|
||||
def switchConfigWindowCompactMode():
|
||||
print(config_window.setting_box_compact_mode_switch_box.get())
|
||||
if config_window.setting_box_compact_mode_switch_box.get() is True:
|
||||
if callable(config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE) is True:
|
||||
config_window.CALLBACK_ENABLE_CONFIG_WINDOW_COMPACT_MODE()
|
||||
else:
|
||||
if callable(config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE) is True:
|
||||
config_window.CALLBACK_DISABLE_CONFIG_WINDOW_COMPACT_MODE()
|
||||
|
||||
|
||||
|
||||
config_window.setting_box_compact_mode_button_container = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0)
|
||||
config_window.setting_box_compact_mode_button_container.grid(row=0, column=1, padx=(0, 20), sticky="nsw")
|
||||
|
||||
|
||||
|
||||
config_window.setting_box_compact_mode_button_container.grid_rowconfigure((0,2), weight=1)
|
||||
config_window.setting_box_compact_mode_button_container = CTkFrame(config_window.setting_box_compact_mode_button_container, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0)
|
||||
config_window.setting_box_compact_mode_button_container.grid(row=1, column=0, sticky="nsew")
|
||||
|
||||
|
||||
config_window.setting_box_compact_mode_button_container.grid_rowconfigure(0, weight=1)
|
||||
config_window.setting_box_compact_mode_label = CTkLabel(
|
||||
config_window.setting_box_compact_mode_button_container,
|
||||
height=0,
|
||||
text="Compact Mode",
|
||||
anchor="w",
|
||||
font=CTkFont(family=settings.FONT_FAMILY, size=12, weight="normal"),
|
||||
text_color=settings.ctm.LABELS_TEXT_COLOR
|
||||
)
|
||||
config_window.setting_box_compact_mode_label.grid(row=0, column=0, padx=(0,10))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
config_window.setting_box_compact_mode_switch_frame = CTkFrame(config_window.setting_box_compact_mode_button_container, corner_radius=0, width=0, height=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR)
|
||||
config_window.setting_box_compact_mode_switch_frame.grid(row=0, column=1, padx=0, sticky="e")
|
||||
|
||||
config_window.setting_box_compact_mode_switch_box = CTkSwitch(
|
||||
config_window.setting_box_compact_mode_switch_frame,
|
||||
text=None,
|
||||
height=0,
|
||||
width=0,
|
||||
# corner_radius=0,
|
||||
border_width=0,
|
||||
switch_width=40,
|
||||
switch_height=16,
|
||||
onvalue=True,
|
||||
offvalue=False,
|
||||
command=switchConfigWindowCompactMode,
|
||||
# fg_color="",
|
||||
# bg_color="red",
|
||||
progress_color=settings.ctm.SB__SWITCH_BOX_ACTIVE_BG_COLOR, # SB__SWITCH_BOX_ACTIVE_BG_COLOR is for SB. change it later.
|
||||
)
|
||||
|
||||
config_window.setting_box_compact_mode_switch_box.select() if settings.IS_CONFIG_WINDOW_COMPACT_MODE else config_window.setting_box_compact_mode_switch_box.deselect()
|
||||
|
||||
config_window.setting_box_compact_mode_switch_box.grid(row=0, column=0)
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel
|
||||
|
||||
def createSettingBoxTitle(config_window, settings):
|
||||
def _createSettingBoxTitle(parent_widget, config_window, settings):
|
||||
|
||||
config_window.grid_columnconfigure(1, weight=1)
|
||||
config_window.main_current_active_config_title_container = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0)
|
||||
config_window.main_current_active_config_title_container.grid(row=0, column=1, sticky="nsew")
|
||||
parent_widget.grid_columnconfigure(0, weight=1)
|
||||
config_window.main_current_active_config_title_container = CTkFrame(parent_widget, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0)
|
||||
config_window.main_current_active_config_title_container.grid(row=0, column=0, sticky="nsew")
|
||||
|
||||
|
||||
config_window.main_current_active_config_title_container.grid_rowconfigure(0, weight=1)
|
||||
@@ -0,0 +1,15 @@
|
||||
from customtkinter import CTkFont, CTkFrame, CTkLabel
|
||||
|
||||
from ._createSettingBoxTitle import _createSettingBoxTitle
|
||||
from ._createSettingBoxCompactModeButton import _createSettingBoxCompactModeButton
|
||||
|
||||
def createSettingBoxTopBar(config_window, settings):
|
||||
|
||||
config_window.grid_columnconfigure(1, weight=1)
|
||||
config_window.setting_box_top_bar = CTkFrame(config_window, corner_radius=0, fg_color=settings.ctm.TOP_BAR_BG_COLOR, width=0, height=0)
|
||||
config_window.setting_box_top_bar.grid(row=0, column=1, sticky="nsew")
|
||||
|
||||
|
||||
_createSettingBoxTitle(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings)
|
||||
|
||||
_createSettingBoxCompactModeButton(parent_widget=config_window.setting_box_top_bar, config_window=config_window, settings=settings)
|
||||
@@ -18,6 +18,19 @@ from config import config
|
||||
class VRCT_GUI(CTk):
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.YOUR_LANGUAGE = "Japanese\n(Japan)"
|
||||
self.TARGET_LANGUAGE = "English\n(United States)"
|
||||
|
||||
self.CALLBACK_TOGGLE_TRANSLATION = None
|
||||
self.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = None
|
||||
self.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = None
|
||||
self.CALLBACK_TOGGLE_FOREGROUND = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_1 = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_2 = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_3 = None
|
||||
|
||||
|
||||
def createGUI(self, settings):
|
||||
self.settings = SimpleNamespace()
|
||||
theme = get_appearance_mode() if config.APPEARANCE_THEME == "System" else config.APPEARANCE_THEME
|
||||
all_ctm = ColorThemeManager(theme)
|
||||
@@ -40,28 +53,14 @@ class VRCT_GUI(CTk):
|
||||
self.settings.config_window = SimpleNamespace(
|
||||
ctm=all_ctm.config_window,
|
||||
uism=all_uism.config_window,
|
||||
IS_CONFIG_WINDOW_COMPACT_MODE=False,
|
||||
IS_CONFIG_WINDOW_COMPACT_MODE=settings.config_window.is_config_window_compact_mode,
|
||||
**common_args
|
||||
)
|
||||
|
||||
|
||||
self.YOUR_LANGUAGE = "Japanese\n(Japan)"
|
||||
self.TARGET_LANGUAGE = "English\n(United States)"
|
||||
|
||||
self.CALLBACK_TOGGLE_TRANSLATION = None
|
||||
self.CALLBACK_TOGGLE_TRANSCRIPTION_SEND = None
|
||||
self.CALLBACK_TOGGLE_TRANSCRIPTION_RECEIVE = None
|
||||
self.CALLBACK_TOGGLE_FOREGROUND = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_1 = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_2 = None
|
||||
self.CALLBACK_SELECTED_TAB_NO_3 = None
|
||||
|
||||
createMainWindowWidgets(vrct_gui=self, settings=self.settings.main)
|
||||
self.config_window = ConfigWindow(vrct_gui=self, settings=self.settings.config_window)
|
||||
# self.information_window = ToplevelWindowInformation(self)
|
||||
|
||||
def createGUI(self):
|
||||
createMainWindowWidgets(vrct_gui=self, settings=self.settings.main)
|
||||
|
||||
def startMainLoop(self):
|
||||
self.mainloop()
|
||||
|
||||
@@ -106,11 +105,11 @@ class VRCT_GUI(CTk):
|
||||
)
|
||||
|
||||
def setDefaultActiveLanguagePresetTab(self, tab_no:str):
|
||||
vrct_gui.current_active_preset_tab = getattr(self, f"sqls__presets_button_{tab_no}")
|
||||
self.current_active_preset_tab = getattr(self, f"sqls__presets_button_{tab_no}")
|
||||
_setDefaultActiveTab(
|
||||
active_tab_widget=vrct_gui.current_active_preset_tab,
|
||||
active_bg_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR,
|
||||
active_text_color=vrct_gui.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR
|
||||
active_tab_widget=self.current_active_preset_tab,
|
||||
active_bg_color=self.settings.main.ctm.SQLS__PRESETS_TAB_BG_ACTIVE_COLOR,
|
||||
active_text_color=self.settings.main.ctm.SQLS__PRESETS_TAB_ACTIVE_TEXT_COLOR
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user