Merge branch 'config_window' into UI_2.0

This commit is contained in:
Sakamoto Shiina
2023-08-28 14:54:10 +09:00
8 changed files with 133 additions and 14 deletions

View File

@@ -4,3 +4,9 @@ from PIL.Image import open as Image_open
def getImageFile(file_name):
img = Image_open(os_path.join(os_path.dirname(__file__), "img", file_name))
return img
def get_key_by_value(dictionary, value):
for key, val in dictionary.items():
if val == value:
return key
return None

View File

@@ -6,7 +6,7 @@ from .addConfigSideMenuItem import addConfigSideMenuItem
from .createSettingBoxContainer import createSettingBoxContainer
from .setting_box_containers import createSettingBox_General
from .setting_box_containers import createSettingBox_Appearance
def createSideMenuAndSettingsBoxContainers(config_window, settings):
@@ -45,16 +45,14 @@ def createSideMenuAndSettingsBoxContainers(config_window, settings):
side_menu_and_setting_box_containers_settings = [
{
"side_menu_tab_attr_name": "side_menu_tab_general",
"label_attr_name": "label_general",
"selected_mark_attr_name": "translation_selected_mark",
"text": "General",
"side_menu_tab_attr_name": "side_menu_tab_appearance",
"label_attr_name": "label_appearance",
"selected_mark_attr_name": "selected_mark_appearance",
"text": "Appearance",
"setting_box_container_settings": {
"setting_box_container_attr_name": "setting_box_container_general",
"setting_box_container_attr_name": "setting_box_container_appearance",
"setting_boxes": [
{ "section_title": None, "setting_box": createSettingBox_General },
# { "section_title": "General Section Title", "setting_box": createSettingBox_General },
# { "section_title": None, "setting_box": createSettingBox_General },
{ "section_title": None, "setting_box": createSettingBox_Appearance },
]
},
"activate_by_default": True,

View File

@@ -3,6 +3,7 @@ from ctk_scrollable_dropdown import CTkScrollableDropdown
from vrct_gui.ui_utils import createButtonWithImage
from typing import Union
class SettingBoxGenerator():
@@ -154,7 +155,7 @@ class SettingBoxGenerator():
def createSettingBoxSlider(self, parent_widget, label_text, desc_text, slider_attr_name, slider_range, slider_number_of_steps, command, variable):
def createSettingBoxSlider(self, parent_widget, label_text, desc_text, slider_attr_name, slider_range, command, variable, slider_number_of_steps: Union[int, None] = None):
(setting_box_frame, setting_box_frame_wrapper) = self._createSettingBoxFrame(parent_widget, label_text, desc_text)
setting_box_slider_frame = CTkFrame(setting_box_frame_wrapper, corner_radius=0, width=0, height=0, fg_color=self.ctm.SB__BG_COLOR)

View File

@@ -1 +1 @@
from .setting_box_general import createSettingBox_General
from .setting_box_appearance import createSettingBox_Appearance

View File

@@ -0,0 +1 @@
from .createSettingBox_Appearance import createSettingBox_Appearance

View File

@@ -7,7 +7,7 @@ from ..SettingBoxGenerator import SettingBoxGenerator
from config import config
def createSettingBox_General(setting_box_wrapper, config_window, settings):
def __tmp(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)

View File

@@ -0,0 +1,114 @@
from time import sleep
from customtkinter import StringVar, IntVar
from tkinter import font as tk_font
from languages import selectable_languages
from utils import get_key_by_value
from ..SettingBoxGenerator import SettingBoxGenerator
from config import config
def createSettingBox_Appearance(setting_box_wrapper, config_window, settings):
sbg = SettingBoxGenerator(config_window, settings)
createSettingBoxDropdownMenu = sbg.createSettingBoxDropdownMenu
createSettingBoxSlider = sbg.createSettingBoxSlider
# 関数名は変えるかもしれない。
# テーマ変更、フォント変更時、 Widget再生成か再起動かは検討中
def slider_transparency_callback(value):
# self.parent.wm_attributes("-alpha", int(value/100))
config.TRANSPARENCY = int(value)
def optionmenu_appearance_theme_callback(value):
config.APPEARANCE_THEME = value
def optionmenu_ui_scaling_callback(value):
# self.optionmenu_ui_scaling.set(choice)
# new_scaling_float = int(choice.replace("%", "")) / 100
config.UI_SCALING = value
def optionmenu_font_family_callback(value):
config.FONT_FAMILY = value
def optionmenu_ui_language_callback(value):
config.UI_LANGUAGE = get_key_by_value(selectable_languages, value)
row=0
config_window.sb__transparency = createSettingBoxSlider(
parent_widget=setting_box_wrapper,
label_text="Transparency",
desc_text="Change the window's transparency. 50% to 100%. (Default: 100%)",
slider_attr_name="sb__transparency_slider",
slider_range=(50, 100),
command=lambda value: slider_transparency_callback(value),
variable=IntVar(value=config.TRANSPARENCY),
)
config_window.sb__transparency.grid(row=row)
row+=1
config_window.sb__appearance_theme = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="Theme",
desc_text="Change the color theme from \"Light\" and \"Dark\". If you select \"System\", It will adjust based on your Windows theme. (Default: System)",
optionmenu_attr_name="sb__appearance_theme_optionmenu",
dropdown_menu_attr_name="sb__appearance_theme_dropdown",
dropdown_menu_values=["Light", "Dark", "System"],
command=lambda value: optionmenu_appearance_theme_callback(value),
variable=StringVar(value=config.APPEARANCE_THEME)
)
config_window.sb__appearance_theme.grid(row=row)
row+=1
config_window.sb__ui_scaling = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="UI Size",
desc_text="(Default: 100%)",
optionmenu_attr_name="sb__ui_scaling_optionmenu",
dropdown_menu_attr_name="sb__ui_scaling_dropdown",
dropdown_menu_values=["80%", "90%", "100%", "110%", "120%"],
command=lambda value: optionmenu_ui_scaling_callback(value),
variable=StringVar(value=config.UI_SCALING)
)
config_window.sb__ui_scaling.grid(row=row)
row+=1
# font_families = list(tk_font.families())
config_window.sb__font_family = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="Font Family",
desc_text="(Default: Yu Gothic UI)",
optionmenu_attr_name="sb__font_family_optionmenu",
dropdown_menu_attr_name="sb__font_family_dropdown",
dropdown_menu_values=["Font A", "Font B"],
# dropdown_menu_values=font_families,
command=lambda value: optionmenu_font_family_callback(value),
variable=StringVar(value=config.FONT_FAMILY)
)
config_window.sb__font_family.grid(row=row)
row+=1
selectable_languages_values = list(selectable_languages.values())
config_window.sb__ui_language = createSettingBoxDropdownMenu(
parent_widget=setting_box_wrapper,
label_text="UI Language",
desc_text="(Default: English)",
optionmenu_attr_name="sb__ui_language_optionmenu",
dropdown_menu_attr_name="sb__ui_language_dropdown",
dropdown_menu_values=selectable_languages_values,
command=lambda value: optionmenu_ui_language_callback(value),
variable=StringVar(value=selectable_languages[config.UI_LANGUAGE]),
)
config_window.sb__ui_language.grid(row=row)
row+=1

View File

@@ -1 +0,0 @@
from .createSettingBox_General import createSettingBox_General