Merge branch 'separate_create_and_show_GUI' into UI_2.0

This commit is contained in:
Sakamoto Shiina
2023-10-11 13:22:17 +09:00
8 changed files with 55 additions and 42 deletions

View File

@@ -600,7 +600,7 @@ def callbackSetOscPort(value):
print("callbackSetOscPort", int(value))
config.OSC_PORT = int(value)
def showMainWindow():
def createMainWindow():
# create GUI
view.createGUI()
@@ -710,4 +710,5 @@ def showMainWindow():
},
)
def showMainWindow():
view.startMainLoop()

View File

@@ -1,4 +1,5 @@
import controller
if __name__ == "__main__":
controller.createMainWindow()
controller.showMainWindow()

35
view.py
View File

@@ -374,7 +374,7 @@ class View():
self.updateGuiVariableByPresetTabNo(config.SELECTED_TAB_NO)
vrct_gui.setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO)
vrct_gui._setDefaultActiveLanguagePresetTab(tab_no=config.SELECTED_TAB_NO)
self.view_variable.CALLBACK_OPEN_SELECTABLE_YOUR_LANGUAGE_WINDOW = self.openSelectableLanguagesWindow_YourLanguage
self.view_variable.CALLBACK_OPEN_SELECTABLE_TARGET_LANGUAGE_WINDOW = self.openSelectableLanguagesWindow_TargetLanguage
@@ -475,11 +475,11 @@ class View():
@staticmethod
def setMainWindowAllWidgetsStatusToNormal():
vrct_gui.changeMainWindowWidgetsStatus("normal", "All")
vrct_gui._changeMainWindowWidgetsStatus("normal", "All")
@staticmethod
def setMainWindowAllWidgetsStatusToDisabled():
vrct_gui.changeMainWindowWidgetsStatus("disabled", "All")
vrct_gui._changeMainWindowWidgetsStatus("disabled", "All")
@@ -503,19 +503,19 @@ class View():
def enableMainWindowSidebarCompactMode(self):
self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = True
vrct_gui.enableMainWindowSidebarCompactMode()
vrct_gui._enableMainWindowSidebarCompactMode()
def disableMainWindowSidebarCompactMode(self):
self.view_variable.IS_MAIN_WINDOW_SIDEBAR_COMPACT_MODE = False
vrct_gui.disableMainWindowSidebarCompactMode()
vrct_gui._disableMainWindowSidebarCompactMode()
def openSelectableLanguagesWindow_YourLanguage(self, _e):
self.view_variable.VAR_TITLE_LABEL_SELECTABLE_LANGUAGE.set(i18n.t("selectable_language_window.title_your_language"))
vrct_gui.openSelectableLanguagesWindow("your_language")
vrct_gui._openSelectableLanguagesWindow("your_language")
def openSelectableLanguagesWindow_TargetLanguage(self, _e):
self.view_variable.VAR_TITLE_LABEL_SELECTABLE_LANGUAGE.set(i18n.t("selectable_language_window.title_target_language"))
vrct_gui.openSelectableLanguagesWindow("target_language")
vrct_gui._openSelectableLanguagesWindow("target_language")
def updateGuiVariableByPresetTabNo(self, tab_no:str):
@@ -582,7 +582,7 @@ class View():
@staticmethod
def _printToTextbox_Info(info_message):
vrct_gui.printToTextbox(
vrct_gui._printToTextbox(
target_type="SYSTEM",
original_message=info_message,
# translated_message="",
@@ -595,7 +595,7 @@ class View():
@staticmethod
def _printToTextbox_Sent(original_message, translated_message):
vrct_gui.printToTextbox(
vrct_gui._printToTextbox(
target_type="SENT",
original_message=original_message,
translated_message=translated_message,
@@ -607,7 +607,7 @@ class View():
@staticmethod
def _printToTextbox_Received(original_message, translated_message):
vrct_gui.printToTextbox(
vrct_gui._printToTextbox(
target_type="RECEIVED",
original_message=original_message,
translated_message=translated_message,
@@ -638,11 +638,16 @@ class View():
def createGUI(self):
vrct_gui.createGUI(settings=self.settings, view_variable=self.view_variable)
vrct_gui._createGUI(settings=self.settings, view_variable=self.view_variable)
@staticmethod
def showGUI():
vrct_gui._showGUI()
@staticmethod
def startMainLoop():
vrct_gui.startMainLoop()
vrct_gui._showGUI()
vrct_gui._startMainLoop()
# Config Window
@@ -659,7 +664,7 @@ class View():
@staticmethod
def setWidgetsStatus_ThresholdCheckButton_Disabled():
vrct_gui.changeConfigWindowWidgetsStatus(
vrct_gui._changeConfigWindowWidgetsStatus(
status="disabled",
target_names=[
"mic_energy_threshold_check_button",
@@ -669,7 +674,7 @@ class View():
@staticmethod
def setWidgetsStatus_ThresholdCheckButton_Normal():
vrct_gui.changeConfigWindowWidgetsStatus(
vrct_gui._changeConfigWindowWidgetsStatus(
status="normal",
target_names=[
"mic_energy_threshold_check_button",
@@ -854,7 +859,7 @@ class View():
def _showErrorMessage(self, target_widget, message):
self.view_variable.VAR_ERROR_MESSAGE.set(message)
vrct_gui.showErrorMessage(target_widget=target_widget)
vrct_gui._showErrorMessage(target_widget=target_widget)
def clearErrorMessage(self):
vrct_gui._clearErrorMessage()

View File

@@ -19,12 +19,12 @@ class _CreateSelectableLanguagesWindow(CTkToplevel):
self.vrct_gui = vrct_gui
self.configure(fg_color="#ff7f50")
self.protocol("WM_DELETE_WINDOW", vrct_gui.closeSelectableLanguagesWindow)
self.protocol("WM_DELETE_WINDOW", vrct_gui._closeSelectableLanguagesWindow)
self.settings = settings
self._view_variable = view_variable
self.bind("<FocusOut>", lambda e: vrct_gui.closeSelectableLanguagesWindow())
self.bind("<FocusOut>", lambda e: vrct_gui._closeSelectableLanguagesWindow())
@@ -63,7 +63,7 @@ class _CreateSelectableLanguagesWindow(CTkToplevel):
target_variable.set(value)
callFunctionIfCallable(callback, value)
self.vrct_gui.closeSelectableLanguagesWindow()
self.vrct_gui._closeSelectableLanguagesWindow()
@@ -98,7 +98,7 @@ class _CreateSelectableLanguagesWindow(CTkToplevel):
bindButtonPressColor([self.go_back_button_container, self.go_back_button_label], self.settings.ctm.GO_BACK_BUTTON_BG_CLICKED_COLOR, self.settings.ctm.GO_BACK_BUTTON_BG_COLOR)
bindButtonReleaseFunction([self.go_back_button_container, self.go_back_button_label], lambda _e: self.vrct_gui.closeSelectableLanguagesWindow())
bindButtonReleaseFunction([self.go_back_button_container, self.go_back_button_label], lambda _e: self.vrct_gui._closeSelectableLanguagesWindow())

View File

@@ -17,7 +17,7 @@ class ConfigWindow(CTkToplevel):
self.configure(fg_color="#ff7f50")
self.protocol("WM_DELETE_WINDOW", vrct_gui.closeConfigWindow)
self.protocol("WM_DELETE_WINDOW", vrct_gui._closeConfigWindow)
self.settings = settings
self._view_variable = view_variable

View File

@@ -6,7 +6,7 @@ from utils import callFunctionIfCallable
from ..ui_utils import createButtonWithImage, getImagePath, bindButtonFunctionAndColor
def createMainWindowWidgets(vrct_gui, settings, view_variable):
vrct_gui.protocol("WM_DELETE_WINDOW", vrct_gui.quitVRCT)
vrct_gui.protocol("WM_DELETE_WINDOW", vrct_gui._quitVRCT)
vrct_gui.iconbitmap(getImagePath("vrct_logo_mark_black.ico"))

View File

@@ -75,5 +75,5 @@ def createSidebar(settings, main_window, view_variable):
enter_color=settings.ctm.CONFIG_BUTTON_HOVERED_BG_COLOR,
leave_color=settings.ctm.CONFIG_BUTTON_BG_COLOR,
clicked_color=settings.ctm.CONFIG_BUTTON_CLICKED_BG_COLOR,
buttonReleasedFunction=main_window.openConfigWindow,
buttonReleasedFunction=main_window._openConfigWindow,
)

View File

@@ -18,12 +18,18 @@ from utils import callFunctionIfCallable
class VRCT_GUI(CTk):
def __init__(self):
super().__init__()
self.withdraw()
self.adjusted_event=None
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID=None
self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID=None
def createGUI(self, settings, view_variable):
def _showGUI(self):
self.deiconify()
self.update()
self.geometry("{}x{}".format(self.winfo_width(), self.winfo_height()))
def _createGUI(self, settings, view_variable):
self.settings = settings
self._view_variable = view_variable
@@ -86,31 +92,31 @@ class VRCT_GUI(CTk):
)
self.update()
self.geometry("{}x{}".format(self.winfo_width(), self.winfo_height()))
# self.update()
# self.geometry("{}x{}".format(self.winfo_width(), self.winfo_height()))
def startMainLoop(self):
def _startMainLoop(self):
self.mainloop()
def quitVRCT(self):
def _quitVRCT(self):
self.quit()
self.destroy()
def openConfigWindow(self, _e):
def _openConfigWindow(self, _e):
callFunctionIfCallable(self._view_variable.CALLBACK_OPEN_CONFIG_WINDOW)
self.adjustToMainWindowGeometry()
self._adjustToMainWindowGeometry()
self.modal_window.deiconify()
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.bind("<Configure>", self.adjustToMainWindowGeometry, "+")
self.BIND_CONFIGURE_ADJUSTED_GEOMETRY_FUNC_ID = self.bind("<Configure>", self._adjustToMainWindowGeometry, "+")
self.BIND_FOCUS_IN_MODAL_WINDOW_LIFT_CONFIG_WINDOW_FUNC_ID = self.modal_window.bind("<FocusIn>", lambda _e: self.config_window.lift(), "+")
self.config_window.deiconify()
self.config_window.focus_set()
def closeConfigWindow(self):
def _closeConfigWindow(self):
callFunctionIfCallable(self._view_variable.CALLBACK_CLOSE_CONFIG_WINDOW)
self.config_window.withdraw()
@@ -122,7 +128,7 @@ class VRCT_GUI(CTk):
def openSelectableLanguagesWindow(self, selectable_language_window_type):
def _openSelectableLanguagesWindow(self, selectable_language_window_type):
# print("___________________________________open____________________________________________________")
# print("your", self._view_variable.IS_OPENED_SELECTABLE_YOUR_LANGUAGE_WINDOW)
# print("target", self._view_variable.IS_OPENED_SELECTABLE_TARGET_LANGUAGE_WINDOW)
@@ -151,7 +157,7 @@ class VRCT_GUI(CTk):
self.selectable_languages_window.attributes("-topmost", True)
def closeSelectableLanguagesWindow(self):
def _closeSelectableLanguagesWindow(self):
self.sls__arrow_img_your_language.configure(image=CTkImage(self.settings.main.image_file.ARROW_LEFT.rotate(180), size=self.settings.main.uism.SLS__BOX_OPTION_MENU_ARROW_IMAGE_SIZE))
self.sls__arrow_img_target_language.configure(image=CTkImage(self.settings.main.image_file.ARROW_LEFT.rotate(180), size=self.settings.main.uism.SLS__BOX_OPTION_MENU_ARROW_IMAGE_SIZE))
self.selectable_languages_window.withdraw()
@@ -168,7 +174,7 @@ class VRCT_GUI(CTk):
def changeMainWindowWidgetsStatus(self, status, target_names):
def _changeMainWindowWidgetsStatus(self, status, target_names):
_changeMainWindowWidgetsStatus(
vrct_gui=self,
settings=self.settings.main,
@@ -177,7 +183,7 @@ class VRCT_GUI(CTk):
target_names=target_names,
)
def changeConfigWindowWidgetsStatus(self, status, target_names):
def _changeConfigWindowWidgetsStatus(self, status, target_names):
_changeConfigWindowWidgetsStatus(
config_window=self.config_window,
settings=self.settings.config_window,
@@ -186,7 +192,7 @@ class VRCT_GUI(CTk):
target_names=target_names,
)
def printToTextbox(self, target_type, original_message=None, translated_message=None):
def _printToTextbox(self, target_type, original_message=None, translated_message=None):
_printToTextbox(
vrct_gui=self,
settings=self.settings.main,
@@ -196,7 +202,7 @@ class VRCT_GUI(CTk):
tags=target_type,
)
def setDefaultActiveLanguagePresetTab(self, tab_no:str):
def _setDefaultActiveLanguagePresetTab(self, tab_no:str):
self.current_active_preset_tab = getattr(self, f"sls__presets_button_{tab_no}")
_setDefaultActiveTab(
active_tab_widget=self.current_active_preset_tab,
@@ -204,20 +210,20 @@ class VRCT_GUI(CTk):
active_text_color=self.settings.main.ctm.SLS__PRESETS_TAB_ACTIVE_TEXT_COLOR
)
def enableMainWindowSidebarCompactMode(self):
def _enableMainWindowSidebarCompactMode(self):
self.sidebar_bg_container.grid_remove()
self.sidebar_compact_mode_bg_container.grid()
self.minimize_sidebar_button_container__for_closing.grid_remove()
self.minimize_sidebar_button_container__for_opening.grid()
def disableMainWindowSidebarCompactMode(self):
def _disableMainWindowSidebarCompactMode(self):
self.sidebar_compact_mode_bg_container.grid_remove()
self.sidebar_bg_container.grid()
self.minimize_sidebar_button_container__for_opening.grid_remove()
self.minimize_sidebar_button_container__for_closing.grid()
def adjustToMainWindowGeometry(self, e=None):
def _adjustToMainWindowGeometry(self, e=None):
self.update_idletasks()
x_pos = self.winfo_rootx()
y_pos = self.winfo_rooty()
@@ -239,7 +245,7 @@ class VRCT_GUI(CTk):
self.adjusted_event=str(e)
def showErrorMessage(self, target_widget):
def _showErrorMessage(self, target_widget):
self.error_message_window.show(target_widget=target_widget)
def _clearErrorMessage(self):