[Update] Main Window: ウィンドウ位置、サイズ。UI Size変更時、それに合わせて保存する値も変化。
This commit is contained in:
@@ -4,14 +4,16 @@ from threading import Thread
|
|||||||
from config import config
|
from config import config
|
||||||
from model import model
|
from model import model
|
||||||
from view import view
|
from view import view
|
||||||
from utils import getKeyByValue, isUniqueStrings
|
from utils import getKeyByValue, isUniqueStrings, strPctToInt
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# Common
|
# Common
|
||||||
def callbackUpdateSoftware():
|
def callbackUpdateSoftware():
|
||||||
|
setMainWindowGeometry()
|
||||||
model.updateSoftware()
|
model.updateSoftware()
|
||||||
|
|
||||||
def callbackRestartSoftware():
|
def callbackRestartSoftware():
|
||||||
|
setMainWindowGeometry()
|
||||||
model.reStartSoftware()
|
model.reStartSoftware()
|
||||||
|
|
||||||
def callbackFilepathLogs():
|
def callbackFilepathLogs():
|
||||||
@@ -23,7 +25,17 @@ def callbackFilepathConfigFile():
|
|||||||
Popen(['explorer', config.LOCAL_PATH.replace('/', '\\')], shell=True)
|
Popen(['explorer', config.LOCAL_PATH.replace('/', '\\')], shell=True)
|
||||||
|
|
||||||
def callbackQuitVrct():
|
def callbackQuitVrct():
|
||||||
main_window_geometry = view.getMainWindowGeometry()
|
setMainWindowGeometry()
|
||||||
|
|
||||||
|
def setMainWindowGeometry():
|
||||||
|
PRE_SCALING_INT = strPctToInt(view.getPreUiScaling())
|
||||||
|
NEW_SCALING_INT = strPctToInt(config.UI_SCALING)
|
||||||
|
MULTIPLY_FLOAT = (NEW_SCALING_INT / PRE_SCALING_INT)
|
||||||
|
main_window_geometry = view.getMainWindowGeometry(return_int=True)
|
||||||
|
main_window_geometry["width"] = str(int(main_window_geometry["width"] * MULTIPLY_FLOAT))
|
||||||
|
main_window_geometry["height"] = str(int(main_window_geometry["height"] * MULTIPLY_FLOAT))
|
||||||
|
main_window_geometry["x_pos"] = str(main_window_geometry["x_pos"])
|
||||||
|
main_window_geometry["y_pos"] = str(main_window_geometry["y_pos"])
|
||||||
config.MAIN_WINDOW_GEOMETRY = main_window_geometry
|
config.MAIN_WINDOW_GEOMETRY = main_window_geometry
|
||||||
|
|
||||||
def messageFormatter(format_type:str, translation, message):
|
def messageFormatter(format_type:str, translation, message):
|
||||||
@@ -398,7 +410,7 @@ def callbackSetAppearance(value):
|
|||||||
def callbackSetUiScaling(value):
|
def callbackSetUiScaling(value):
|
||||||
print("callbackSetUiScaling", value)
|
print("callbackSetUiScaling", value)
|
||||||
config.UI_SCALING = value
|
config.UI_SCALING = value
|
||||||
new_scaling_float = int(value.replace("%", "")) / 100
|
new_scaling_float = strPctToInt(value) / 100
|
||||||
print("callbackSetUiScaling_new_scaling_float", new_scaling_float)
|
print("callbackSetUiScaling_new_scaling_float", new_scaling_float)
|
||||||
view.showRestartButtonIfRequired()
|
view.showRestartButtonIfRequired()
|
||||||
|
|
||||||
|
|||||||
5
utils.py
5
utils.py
@@ -30,9 +30,12 @@ def generatePercentageStringsList(start:int, end:int, step:int):
|
|||||||
strings.append(f"{percent}%")
|
strings.append(f"{percent}%")
|
||||||
return strings
|
return strings
|
||||||
|
|
||||||
def intToPercentageStringsFormatter(value:int):
|
def intToPctStr(value:int):
|
||||||
return f"{value}%"
|
return f"{value}%"
|
||||||
|
|
||||||
|
def strPctToInt(value:str):
|
||||||
|
return int(value.replace("%", ""))
|
||||||
|
|
||||||
def isUniqueStrings(unique_strings:Union[str, list], input_string:str, require=False):
|
def isUniqueStrings(unique_strings:Union[str, list], input_string:str, require=False):
|
||||||
import re
|
import re
|
||||||
if isinstance(unique_strings, str):
|
if isinstance(unique_strings, str):
|
||||||
|
|||||||
20
view.py
20
view.py
@@ -8,7 +8,7 @@ import i18n
|
|||||||
from customtkinter import StringVar, IntVar, BooleanVar, get_appearance_mode
|
from customtkinter import StringVar, IntVar, BooleanVar, get_appearance_mode
|
||||||
from vrct_gui.ui_managers import ColorThemeManager, UiScalingManager
|
from vrct_gui.ui_managers import ColorThemeManager, UiScalingManager
|
||||||
from vrct_gui import vrct_gui
|
from vrct_gui import vrct_gui
|
||||||
from utils import callFunctionIfCallable, intToPercentageStringsFormatter
|
from utils import callFunctionIfCallable, intToPctStr
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ class View():
|
|||||||
VAR_CONFIG_WINDOW_COMPACT_MODE_LABEL=StringVar(value=i18n.t("config_window.compact_mode")),
|
VAR_CONFIG_WINDOW_COMPACT_MODE_LABEL=StringVar(value=i18n.t("config_window.compact_mode")),
|
||||||
VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL=StringVar(value=i18n.t("config_window.restart_message")),
|
VAR_CONFIG_WINDOW_RESTART_BUTTON_LABEL=StringVar(value=i18n.t("config_window.restart_message")),
|
||||||
|
|
||||||
CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER=intToPercentageStringsFormatter,
|
CALLBACK_SLIDER_TOOLTIP_PERCENTAGE_FORMATTER=intToPctStr,
|
||||||
|
|
||||||
|
|
||||||
# Side Menu Labels
|
# Side Menu Labels
|
||||||
@@ -796,14 +796,24 @@ class View():
|
|||||||
webbrowser.open_new_tab(url)
|
webbrowser.open_new_tab(url)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getMainWindowGeometry():
|
def getMainWindowGeometry(return_int:bool=False):
|
||||||
result = {
|
if return_int is True:
|
||||||
|
return {
|
||||||
|
"width": vrct_gui.winfo_toplevel().winfo_width(),
|
||||||
|
"height": vrct_gui.winfo_toplevel().winfo_height(),
|
||||||
|
"x_pos": vrct_gui.winfo_toplevel().winfo_x(),
|
||||||
|
"y_pos": vrct_gui.winfo_toplevel().winfo_y(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
"width": str(vrct_gui.winfo_toplevel().winfo_width()),
|
"width": str(vrct_gui.winfo_toplevel().winfo_width()),
|
||||||
"height": str(vrct_gui.winfo_toplevel().winfo_height()),
|
"height": str(vrct_gui.winfo_toplevel().winfo_height()),
|
||||||
"x_pos": str(vrct_gui.winfo_toplevel().winfo_x()),
|
"x_pos": str(vrct_gui.winfo_toplevel().winfo_x()),
|
||||||
"y_pos": str(vrct_gui.winfo_toplevel().winfo_y()),
|
"y_pos": str(vrct_gui.winfo_toplevel().winfo_y()),
|
||||||
}
|
}
|
||||||
return result
|
|
||||||
|
def getPreUiScaling(self):
|
||||||
|
return self.restart_required_configs_pre_data.ui_scaling
|
||||||
|
|
||||||
# Open Webpage Functions
|
# Open Webpage Functions
|
||||||
def openWebPage_Booth(self):
|
def openWebPage_Booth(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user