[bugfix/Refactor] Config Window: Setting Box周り。謎の1pxバグ修正(無理やり)と、要素の幅が合っておらず、文字数などの影響により幅が広くなり、意図していない線が見えていたのを修正。

(rowやcolumn, sticky指定、セクションタイトルの指定方法の変更など。)
This commit is contained in:
Sakamoto Shiina
2023-10-01 13:28:37 +09:00
parent 49ac0a62d4
commit c287df5c10
2 changed files with 59 additions and 58 deletions

View File

@@ -5,56 +5,55 @@ def _createSettingBoxContainer(config_window, settings, view_variable, setting_b
def createSectionTitle(container_widget, var_section_title):
setting_box_wrapper_section_title_frame = CTkFrame(container_widget, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
setting_box_wrapper_section_title = CTkLabel(
setting_box_wrapper_section_title_frame,
container_widget,
textvariable=var_section_title,
anchor="w",
height=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SB__SECTION_TITLE_FONT_SIZE, weight="normal"),
text_color=settings.ctm.LABELS_TEXT_COLOR
)
setting_box_wrapper_section_title.grid(row=0, column=0, padx=0, pady=settings.uism.SB__SECTION_TITLE_BOTTOM_PADY)
setting_box_wrapper_section_title.place(relx=0, rely=0)
# setting_box_wrapper_section_title.grid(row=0, column=0, padx=0, pady=settings.uism.SB__SECTION_TITLE_BOTTOM_PADY)
return setting_box_wrapper_section_title_frame
return container_widget
# Setting box container
setting_box_container_widget = CTkFrame(config_window.main_setting_box_bg_wrapper, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=0)
setattr(config_window, setting_box_container_settings["setting_box_container_attr_name"], setting_box_container_widget)
setting_box_container_widget.grid(row=0, pady=settings.uism.SB__BOTTOM_MARGIN)
setting_box_container_widget.grid_remove()
setting_boxes_length = len(setting_box_container_settings["setting_boxes"])
setting_box_row = 0
# setting_boxes_length = len(setting_box_container_settings["setting_boxes"])
setting_box_row=0
for i, setting_box_setting in enumerate(setting_box_container_settings["setting_boxes"]):
SB__TOP_PADY = 0
SB__BOTTOM_PADY = settings.uism.SB__BOTTOM_PADY
setting_box_and_section_title_wrapper = CTkFrame(setting_box_container_widget, fg_color=settings.ctm.SB__WRAPPER_BG_COLOR, corner_radius=0, width=0, height=0)
if setting_box_setting["var_section_title"] is not None:
setting_box_wrapper_section_title_frame= createSectionTitle(
container_widget=setting_box_and_section_title_wrapper,
var_section_title=setting_box_setting["var_section_title"],
)
setting_box_wrapper_section_title_frame.grid(row=0, column=0, sticky="ew", padx=0, pady=0)
if i == 0: SB__TOP_PADY = settings.uism.SB__TOP_PADY_IF_WITH_SECTION_TITLE
# if the first one of setting boxes, adjust top pady
if i == 0: SB__TOP_PADY = settings.uism.SB__TOP_PADY_IF_WITHOUT_SECTION_TITLE
# if the last one of setting boxes, remove bottom pady
if i+1 == setting_boxes_length: SB__BOTTOM_PADY = 0
# setting_box_wrapper = CTkFrame(setting_box_and_section_title_wrapper, fg_color="red", corner_radius=0, width=0, height=0)
setting_box_wrapper = CTkFrame(setting_box_and_section_title_wrapper, fg_color=settings.ctm.SB__WRAPPER_BG_COLOR, corner_radius=0, width=0, height=0)
setting_box_wrapper.grid(row=1, column=0)
# Top-Padding that can be container the section title
setting_box_top_padding = CTkFrame(setting_box_container_widget, corner_radius=0, fg_color=settings.ctm.MAIN_BG_COLOR, width=0, height=60)
setting_box_top_padding.grid(row=setting_box_row, column=0, sticky="ew", padx=0, pady=0)
setting_box_top_padding.grid_columnconfigure(0, weight=1)
setting_box_row+=1
if setting_box_setting["var_section_title"] is not None:
setting_box_wrapper_section_title = CTkLabel(
setting_box_top_padding,
textvariable=setting_box_setting["var_section_title"],
anchor="w",
height=0,
font=CTkFont(family=settings.FONT_FAMILY, size=settings.uism.SB__SECTION_TITLE_FONT_SIZE, weight="normal"),
text_color=settings.ctm.LABELS_TEXT_COLOR
)
setting_box_wrapper_section_title.place(relx=0, rely=0.4, anchor="nw")
setting_box_wrapper = CTkFrame(setting_box_container_widget, fg_color=settings.ctm.SB__WRAPPER_BG_COLOR, corner_radius=0, width=0, height=0)
setting_box_wrapper.grid(row=setting_box_row, column=0, sticky="ew")
setting_box_wrapper.grid_columnconfigure(0, weight=1)
setting_box_row+=1
setting_box_and_section_title_wrapper.grid(row=setting_box_row, column=0, sticky="ew", padx=0, pady=(SB__TOP_PADY, SB__BOTTOM_PADY))
if setting_box_setting["setting_box"] is not None:
setting_box_setting["setting_box"](