Skip to content

Commit

Permalink
Update options_builder.py
Browse files Browse the repository at this point in the history
  • Loading branch information
kelltom committed May 12, 2023
1 parent d22c000 commit 848b10b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/utilities/options_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,16 @@ def __init__(self, title, placeholder):
self.placeholder = placeholder


class OptionsUI(customtkinter.CTkFrame):
class OptionsUI(customtkinter.CTkScrollableFrame):
WIDTH = 500
HEIGHT = 500

def __init__(self, parent, title: str, option_info: dict, controller):
# sourcery skip: raise-specific-error
super().__init__(parent)

parent.minsize(self.WIDTH, self.HEIGHT)

# Contains the widgets for option selection.
# It will be queried to get the option values selected upon save btn clicked.
self.widgets: Dict[str, customtkinter.CTkBaseClass] = {}
Expand Down Expand Up @@ -151,7 +157,7 @@ def create_slider(self, key, value: SliderInfo, row: int):
self.frames[key].grid(row=row, column=1, sticky="ew", padx=(0, 10))
# Slider value indicator
self.slider_values[key] = customtkinter.CTkLabel(master=self.frames[key], text=str(value.min), font=small_font())
self.slider_values[key].grid(row=0, column=1)
self.slider_values[key].grid(row=0, column=1, padx=5)
# Slider widget
self.widgets[key] = customtkinter.CTkSlider(
master=self.frames[key],
Expand All @@ -167,7 +173,7 @@ def create_checkboxes(self, key, value: CheckboxInfo, row: int):
Creates checkbox widgets and adds them to the view.
"""
# Checkbox label
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title)
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title, font=small_font())
self.labels[key].grid(row=row, column=0, padx=10, pady=20)
# Checkbox frame
self.frames[key] = customtkinter.CTkFrame(master=self)
Expand All @@ -177,19 +183,21 @@ def create_checkboxes(self, key, value: CheckboxInfo, row: int):
# Checkbox values
self.widgets[key]: List[customtkinter.CTkCheckBox] = []
for i, value in enumerate(value.values):
self.widgets[key].append(customtkinter.CTkCheckBox(master=self.frames[key], text=value))
self.widgets[key].append(customtkinter.CTkCheckBox(master=self.frames[key], text=value, font=small_font()))
self.widgets[key][i].grid(row=0, column=i, sticky="ew", padx=5, pady=5)

def create_menu(self, key, value: OptionMenuInfo, row: int):
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title)
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title, font=small_font())
self.labels[key].grid(row=row, column=0, sticky="nsew", padx=10, pady=20)
self.widgets[key] = customtkinter.CTkOptionMenu(master=self, values=value.values, fg_color=("gray75", "gray22"))
self.widgets[key] = customtkinter.CTkOptionMenu(
master=self, values=value.values, fg_color=("gray75", "gray22"), font=small_font(), dropdown_font=small_font()
)
self.widgets[key].grid(row=row, column=1, sticky="ew", padx=(0, 10))

def create_text_edit(self, key, value: TextEditInfo, row: int):
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title)
self.labels[key] = customtkinter.CTkLabel(master=self, text=value.title, font=small_font())
self.labels[key].grid(row=row, column=0, sticky="nsew", padx=10, pady=20)
self.widgets[key] = customtkinter.CTkEntry(master=self, corner_radius=5, placeholder_text=value.placeholder)
self.widgets[key] = customtkinter.CTkEntry(master=self, corner_radius=5, font=small_font(), placeholder_text=value.placeholder)
self.widgets[key].grid(row=row, column=1, sticky="ew", padx=(0, 10))

def save(self, window):
Expand Down

0 comments on commit 848b10b

Please sign in to comment.