[Update] Config Window: Dropdown Menu Window. Width指定。フォントやデバイスなどテキストが長くなるものは幅を広めに。(可変は難しいので今は指定型に)
This commit is contained in:
@@ -38,6 +38,14 @@ class _CreateDropdownMenuWindow(CTkToplevel):
|
||||
self.x_pos = None
|
||||
self.y_pos = None
|
||||
|
||||
self.init_height = 200
|
||||
self.new_height = self.init_height
|
||||
self.init_width = 200
|
||||
self.new_width = self.init_width
|
||||
|
||||
self.init_max_display_length = 8
|
||||
self.max_display_length = self.init_max_display_length
|
||||
|
||||
|
||||
|
||||
# self.rowconfigure(0,weight=1)
|
||||
@@ -50,10 +58,19 @@ class _CreateDropdownMenuWindow(CTkToplevel):
|
||||
dropdown_menu_values=dropdown_menu_values,
|
||||
command=self.dropdown_menu_widgets[dropdown_menu_widget_id].command,
|
||||
wrapper_widget=self.dropdown_menu_widgets[dropdown_menu_widget_id].wrapper_widget,
|
||||
|
||||
dropdown_menu_width=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.dropdown_menu_width,
|
||||
dropdown_menu_height=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.dropdown_menu_height,
|
||||
max_display_length=self.dropdown_menu_widgets[dropdown_menu_widget_id].dropdown_menu_settings.max_display_length,
|
||||
)
|
||||
|
||||
|
||||
def createDropdownMenuBox(self, dropdown_menu_widget_id, dropdown_menu_values, command, wrapper_widget):
|
||||
def createDropdownMenuBox(self, dropdown_menu_widget_id, dropdown_menu_values, command, wrapper_widget, dropdown_menu_width=None, dropdown_menu_height=None, max_display_length=None):
|
||||
self.new_width = dropdown_menu_width if dropdown_menu_width is not None else self.init_width
|
||||
self.new_height = dropdown_menu_height if dropdown_menu_height is not None else self.init_height
|
||||
self.max_display_length = max_display_length if max_display_length is not None else self.init_max_display_length
|
||||
|
||||
|
||||
self.wrapper_widget = wrapper_widget
|
||||
|
||||
self.dropdown_menu_container = CTkFrame(self, corner_radius=0, fg_color="#bb4448", width=0, height=0)
|
||||
@@ -66,6 +83,11 @@ class _CreateDropdownMenuWindow(CTkToplevel):
|
||||
widget=self.dropdown_menu_container,
|
||||
command=command,
|
||||
wrapper_widget=wrapper_widget,
|
||||
dropdown_menu_settings=SimpleNamespace(
|
||||
dropdown_menu_width=dropdown_menu_width,
|
||||
dropdown_menu_height=dropdown_menu_height,
|
||||
max_display_length=max_display_length,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -119,16 +141,12 @@ class _CreateDropdownMenuWindow(CTkToplevel):
|
||||
# ______________________________________
|
||||
|
||||
dropdown_menu_values_length = len(dropdown_menu_values)
|
||||
new_height = 200
|
||||
new_width = 200
|
||||
max_display_length = 8
|
||||
if dropdown_menu_values_length < max_display_length:
|
||||
if dropdown_menu_values_length < self.max_display_length:
|
||||
new_height = int(dropdown_menu_values_length * label_height)
|
||||
# new_width = 200
|
||||
else:
|
||||
new_height = int(max_display_length * label_height)
|
||||
new_height = int(self.max_display_length * label_height)
|
||||
|
||||
self.scroll_frame_container.configure(width=new_width, height=new_height)
|
||||
self.scroll_frame_container.configure(width=self.new_width, height=new_height)
|
||||
|
||||
# This is for CustomTkinter's spec change or bug fix.
|
||||
self.scroll_frame_container._scrollbar.configure(height=0)
|
||||
|
||||
@@ -82,7 +82,7 @@ class _SettingBoxGenerator():
|
||||
self.config_window.additional_widgets.append(setting_box_desc)
|
||||
|
||||
|
||||
def createSettingBoxDropdownMenu(self, for_var_label_text, for_var_desc_text, optionmenu_attr_name, command, variable=None, dropdown_menu_values=None):
|
||||
def createSettingBoxDropdownMenu(self, for_var_label_text, for_var_desc_text, optionmenu_attr_name, command, dropdown_menu_width=None, variable=None, dropdown_menu_values=None):
|
||||
(setting_box_frame, setting_box_item_frame) = self._createSettingBoxFrame(for_var_label_text, for_var_desc_text)
|
||||
|
||||
def adjustedCommand(value):
|
||||
@@ -94,6 +94,7 @@ class _SettingBoxGenerator():
|
||||
dropdown_menu_values=dropdown_menu_values,
|
||||
command=adjustedCommand,
|
||||
wrapper_widget=self.config_window.main_bg_container,
|
||||
dropdown_menu_width=dropdown_menu_width,
|
||||
)
|
||||
|
||||
option_menu_widget = createOptionMenuBox(
|
||||
|
||||
@@ -68,6 +68,7 @@ def createSettingBox_Appearance(setting_box_wrapper, config_window, settings, vi
|
||||
for_var_desc_text=view_variable.VAR_DESC_FONT_FAMILY,
|
||||
optionmenu_attr_name="sb__optionmenu_font_family",
|
||||
dropdown_menu_values=view_variable.LIST_FONT_FAMILY,
|
||||
dropdown_menu_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300,
|
||||
command=lambda value: optionmenu_font_family_callback(value),
|
||||
variable=view_variable.VAR_FONT_FAMILY,
|
||||
)
|
||||
|
||||
@@ -58,6 +58,7 @@ def createSettingBox_Mic(setting_box_wrapper, config_window, settings, view_vari
|
||||
for_var_desc_text=view_variable.VAR_DESC_MIC_DEVICE,
|
||||
optionmenu_attr_name="sb__optionmenu_mic_device",
|
||||
dropdown_menu_values=view_variable.LIST_MIC_DEVICE,
|
||||
dropdown_menu_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300,
|
||||
command=lambda value: optionmenu_input_mic_device_callback(value),
|
||||
variable=view_variable.VAR_MIC_DEVICE,
|
||||
)
|
||||
|
||||
@@ -41,6 +41,7 @@ def createSettingBox_Speaker(setting_box_wrapper, config_window, settings, view_
|
||||
for_var_desc_text=view_variable.VAR_DESC_SPEAKER_DEVICE,
|
||||
optionmenu_attr_name="sb__optionmenu_speaker_device",
|
||||
dropdown_menu_values=view_variable.LIST_SPEAKER_DEVICE,
|
||||
dropdown_menu_width=settings.uism.RESPONSIVE_UI_SIZE_INT_300,
|
||||
command=lambda value: optionmenu_input_speaker_device_callback(value),
|
||||
variable=view_variable.VAR_SPEAKER_DEVICE,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user