[bugfix] Main Window: UI崩壊修正 Windows本体でスケーリングを変更している場合にUIが崩れるのを修正。DPIを固定するためにctypesを使っているため、requirements.txtに追加。

This commit is contained in:
Sakamoto Shiina
2023-10-15 11:32:38 +09:00
parent e5238fd4a7
commit 465f9f9628
7 changed files with 18 additions and 23 deletions

View File

@@ -1,3 +1,6 @@
import ctypes
ctypes.windll.shcore.SetProcessDpiAwareness(1)
from vrct_gui.splash_window import SplashWindow from vrct_gui.splash_window import SplashWindow
splash = SplashWindow() splash = SplashWindow()
splash.showSplash() splash.showSplash()

View File

@@ -6,3 +6,4 @@ deepl == 1.15.0
flashtext == 2.7 flashtext == 2.7
pyyaml == 6.0.1 pyyaml == 6.0.1
python-i18n == 0.3.9 python-i18n == 0.3.9
ctypes

View File

@@ -38,7 +38,6 @@ class View():
self.settings.main = SimpleNamespace( self.settings.main = SimpleNamespace(
ctm=all_ctm.main, ctm=all_ctm.main,
uism=all_uism.main, uism=all_uism.main,
COMPACT_MODE_ICON_SIZE=0,
**common_args **common_args
) )

View File

@@ -1,8 +1,6 @@
from customtkinter import CTkImage from customtkinter import CTkImage
def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names): def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, target_names):
COMPACT_MODE_ICON_SIZE_TUPLES = (settings.COMPACT_MODE_ICON_SIZE, settings.COMPACT_MODE_ICON_SIZE)
if target_names == "All": if target_names == "All":
target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box"] target_names = ["translation_switch", "transcription_send_switch", "transcription_receive_switch", "foreground_switch", "quick_language_settings", "config_button", "minimize_sidebar_button", "entry_message_box"]
@@ -32,7 +30,7 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta
widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_ACTIVE_BG_COLOR) widget_selected_mark.configure(fg_color=settings.ctm.SF__SELECTED_MARK_ACTIVE_BG_COLOR)
icon_file = icon_name icon_file = icon_name
image = CTkImage(icon_file, size=COMPACT_MODE_ICON_SIZE_TUPLES) image = CTkImage(icon_file, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE)
widget_compact_mode_icon.configure(image=image) widget_compact_mode_icon.configure(image=image)
@@ -109,12 +107,12 @@ def _changeMainWindowWidgetsStatus(vrct_gui, settings, view_variable, status, ta
if status == "disabled": if status == "disabled":
vrct_gui.sidebar_config_button_wrapper.configure(cursor="") vrct_gui.sidebar_config_button_wrapper.configure(cursor="")
vrct_gui.sidebar_config_button.configure( vrct_gui.sidebar_config_button.configure(
image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, size=COMPACT_MODE_ICON_SIZE_TUPLES), image=CTkImage(settings.image_file.CONFIGURATION_ICON_DISABLED, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
) )
elif status == "normal": elif status == "normal":
vrct_gui.sidebar_config_button_wrapper.configure(cursor="hand2") vrct_gui.sidebar_config_button_wrapper.configure(cursor="hand2")
vrct_gui.sidebar_config_button.configure( vrct_gui.sidebar_config_button.configure(
image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=COMPACT_MODE_ICON_SIZE_TUPLES), image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
) )

View File

@@ -217,11 +217,6 @@ def createSidebarFeatures(settings, main_window, view_variable):
setattr(main_window, switch_box_attr_name, switch_box_widget) setattr(main_window, switch_box_attr_name, switch_box_widget)
if settings.COMPACT_MODE_ICON_SIZE == 0:
label_widget.grid(row=row, column=0, pady=settings.uism.SF__LABELS_IPADY, padx=(settings.uism.SF__LABEL_LEFT_PAD,0), sticky="ew")
settings.COMPACT_MODE_ICON_SIZE = int(getLatestHeight(frame_widget) - settings.uism.SF__COMPACT_MODE_ICON_PADY*2)
label_widget.grid_remove()
# for compact mode # for compact mode
compact_mode_icon_widget = CTkLabel( compact_mode_icon_widget = CTkLabel(
@@ -229,7 +224,7 @@ def createSidebarFeatures(settings, main_window, view_variable):
text=None, text=None,
height=0, height=0,
corner_radius=0, corner_radius=0,
image=CTkImage((icon_file),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)), image=CTkImage(icon_file, size=settings.uism.SF__COMPACT_MODE_IMAGE_SIZE),
) )
setattr(main_window, compact_mode_icon_attr_name, compact_mode_icon_widget) setattr(main_window, compact_mode_icon_attr_name, compact_mode_icon_widget)
@@ -244,11 +239,11 @@ def createSidebarFeatures(settings, main_window, view_variable):
# Arrange # Arrange
compact_mode_icon_widget.grid(row=row, column=0, pady=settings.uism.SF__COMPACT_MODE_ICON_PADY) compact_mode_icon_widget.grid(row=row, column=0, padx=settings.uism.SF__COMPACT_MODE_ICON_PADX, pady=settings.uism.SF__COMPACT_MODE_ICON_PADY)
selected_mark_widget.place(relx=-1, rely=0.5, relheight=0.75, anchor="center") selected_mark_widget.place(relx=-1, rely=0.5, relheight=0.75, anchor="center")
label_widget.grid(row=row, column=0, pady=settings.uism.SF__LABELS_IPADY, padx=(settings.uism.SF__LABEL_LEFT_PAD,0), sticky="ew") label_widget.grid(row=row, column=0, pady=settings.uism.SF__LABELS_IPADY, padx=(settings.uism.SF__LABEL_LEFT_PAD,0), sticky="ew")
switch_box_widget.grid(row=row, column=0, padx=(0,settings.uism.SF__SWITCH_BOX_RIGHT_PAD), sticky="e") switch_box_widget.grid(row=row, column=1, padx=settings.uism.SF__SWITCH_BOX_PADX, sticky="e")
# Unbind the event "<Button-1>" originally set up by the widget to manually control it. # Unbind the event "<Button-1>" originally set up by the widget to manually control it.

View File

@@ -16,8 +16,8 @@ def createSidebar(settings, main_window, view_variable):
main_window.sidebar_compact_mode_bg_container = CTkFrame(main_window.sidebar_bg_container_wrapper, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0) main_window.sidebar_compact_mode_bg_container = CTkFrame(main_window.sidebar_bg_container_wrapper, corner_radius=0, fg_color=settings.ctm.SIDEBAR_BG_COLOR, width=0, height=0)
main_window.sidebar_bg_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.SIDEBAR_MIN_WIDTH) main_window.sidebar_bg_container.grid_columnconfigure(0, weight=1)
main_window.sidebar_compact_mode_bg_container.grid_columnconfigure(0, weight=0, minsize=settings.uism.COMPACT_MODE_SIDEBAR_MIN_WIDTH) main_window.sidebar_compact_mode_bg_container.grid_columnconfigure(0, weight=1)
createSidebarFeatures(settings, main_window, view_variable) createSidebarFeatures(settings, main_window, view_variable)
@@ -45,12 +45,11 @@ def createSidebar(settings, main_window, view_variable):
main_window.sidebar_config_button_wrapper.grid_columnconfigure(0, weight=1) main_window.sidebar_config_button_wrapper.grid_columnconfigure(0, weight=1)
settings.uism.CONFIG_BUTTON_PADX = 0
main_window.sidebar_config_button = CTkLabel( main_window.sidebar_config_button = CTkLabel(
main_window.sidebar_config_button_wrapper, main_window.sidebar_config_button_wrapper,
text=None, text=None,
height=0, height=0,
image=CTkImage((settings.image_file.CONFIGURATION_ICON),size=(settings.COMPACT_MODE_ICON_SIZE,settings.COMPACT_MODE_ICON_SIZE)) image=CTkImage(settings.image_file.CONFIGURATION_ICON, size=settings.uism.SIDEBAR_CONFIG_BUTTON_IMAGE_SIZE)
) )
main_window.sidebar_config_button.grid(row=0, column=0, padx=0, pady=settings.uism.SIDEBAR_CONFIG_BUTTON_IPADY) main_window.sidebar_config_button.grid(row=0, column=0, padx=0, pady=settings.uism.SIDEBAR_CONFIG_BUTTON_IPADY)

View File

@@ -54,9 +54,6 @@ class UiScalingManager():
# Sidebar # Sidebar
self.main.SIDEBAR_MIN_WIDTH = self._calculateUiSize(230)
self.main.COMPACT_MODE_SIDEBAR_MIN_WIDTH = self._calculateUiSize(60)
# Sidebar Features # Sidebar Features
self.main.SF__LOGO_MAX_SIZE = self._calculateUiSize(120) self.main.SF__LOGO_MAX_SIZE = self._calculateUiSize(120)
self.main.SF__LOGO_PADY = (self._calculateUiSize(12),self._calculateUiSize(8)) self.main.SF__LOGO_PADY = (self._calculateUiSize(12),self._calculateUiSize(8))
@@ -64,10 +61,12 @@ class UiScalingManager():
self.main.SF__LABELS_IPADY = self._calculateUiSize(16) self.main.SF__LABELS_IPADY = self._calculateUiSize(16)
self.main.SF__COMPACT_MODE_ICON_PADY = self.main.SF__LABELS_IPADY self.main.SF__COMPACT_MODE_ICON_PADY = self.main.SF__LABELS_IPADY
self.main.SF__COMPACT_MODE_ICON_PADX = self.main.SF__COMPACT_MODE_ICON_PADY
self.main.SF__LABEL_LEFT_PAD = self._calculateUiSize(20) self.main.SF__LABEL_LEFT_PAD = self._calculateUiSize(20)
self.main.SF__LABEL_FONT_SIZE = self._calculateUiSize(16) self.main.SF__LABEL_FONT_SIZE = self._calculateUiSize(16)
self.main.SF__COMPACT_MODE_IMAGE_SIZE = (self._calculateUiSize(20), self._calculateUiSize(20))
self.main.SF__SWITCH_BOX_RIGHT_PAD = self._calculateUiSize(10) self.main.SF__SWITCH_BOX_PADX = (self.main.SF__LABEL_LEFT_PAD, self._calculateUiSize(10))
self.main.SF__SWITCH_BOX_WIDTH = self._calculateUiSize(40) self.main.SF__SWITCH_BOX_WIDTH = self._calculateUiSize(40)
self.main.SF__SWITCH_BOX_HEIGHT = self._calculateUiSize(16) self.main.SF__SWITCH_BOX_HEIGHT = self._calculateUiSize(16)
@@ -98,6 +97,7 @@ class UiScalingManager():
self.main.SLS__BOX_TOP_PADY = self._calculateUiSize(16) self.main.SLS__BOX_TOP_PADY = self._calculateUiSize(16)
self.main.SIDEBAR_CONFIG_BUTTON_CORNER_RADIUS = self._calculateUiSize(6) self.main.SIDEBAR_CONFIG_BUTTON_CORNER_RADIUS = self._calculateUiSize(6)
self.main.SIDEBAR_CONFIG_BUTTON_IMAGE_SIZE = self.main.SF__COMPACT_MODE_IMAGE_SIZE
self.main.SIDEBAR_CONFIG_BUTTON_PADX = self._calculateUiSize(10) self.main.SIDEBAR_CONFIG_BUTTON_PADX = self._calculateUiSize(10)
self.main.SIDEBAR_CONFIG_BUTTON_PADY = self._calculateUiSize(10) self.main.SIDEBAR_CONFIG_BUTTON_PADY = self._calculateUiSize(10)
self.main.SIDEBAR_CONFIG_BUTTON_IPADY = self._calculateUiSize(8) self.main.SIDEBAR_CONFIG_BUTTON_IPADY = self._calculateUiSize(8)