import customtkinter as Ctk import scripts.get_sys_info as system_code from scripts.Colorpicker import AskColor class Settings(Ctk.CTkFrame): def __init__(self,master, **kwargs): super().__init__(master, **kwargs) system_code.load_json_file() self.my_font = Ctk.CTkFont(family="Berlin Sans FB", size=22) self.color_information = Ctk.CTkLabel(self, text="Bounding Box Color: ", width=100, font=self.my_font) self.color_btn = Ctk.CTkButton(self, text="Set Color",fg_color=system_code.color, width=100, command=self.ask_color, font=self.my_font) # set the time for skiping frames self.thickness_label = Ctk.CTkLabel(self, text="Bounding Box Thickness:", width=100, font=self.my_font) self.thickness_slider = Ctk.CTkSlider(self, from_=1, to=100, command=self.change_thickness) self.thickness_slider_value = Ctk.CTkLabel(self, text=system_code.thickness, width=100, font=self.my_font) self.thickness_slider.set(system_code.thickness) # set the time for skiping frames self.skip_label = Ctk.CTkLabel(self, text="Skipable Frames:", width=100, font=self.my_font) self.skip_slider = Ctk.CTkSlider(self, from_=2, to=100, command=self.change_skipped_frame) self.skip_slider_value = Ctk.CTkLabel(self, text=system_code.skipable_frames, width=100, font=self.my_font) self.skip_slider.set(system_code.skipable_frames) # set the outputs self.label_output_formats = Ctk.CTkLabel(self, text="Output formats:", width=256, font=self.my_font) self.change_output_format = Ctk.StringVar(value=system_code.img_format) self.output_formats = Ctk.CTkSegmentedButton(self, values= system_code.img_format_options, command=self.set_img_format, variable=self.change_output_format,width=64,font=self.my_font) # set the threads self.label_threads = Ctk.CTkLabel(self, text="Threads: ", width=196, font=self.my_font) self.thread_switcher = Ctk.StringVar(value=system_code.thread_detection_mode) self.thread_switch = Ctk.CTkSegmentedButton(self, values=system_code.thread_switcher, command=self.change_thread_type, variable=self.thread_switcher, width=64,font=self.my_font) self.used_threads = Ctk.StringVar(value=system_code.used_threads) self.thread_count_switch = Ctk.CTkSegmentedButton(self, values=system_code.thread_options, command=self.change_manual_threads, width=256,font=self.my_font) if system_code.thread_detection_mode == "manual": self.show_thread_selection() self.thread_count_switch.set(system_code.used_threads) # Position of the Frame self.align() def enable_keybinding(self): # this function has to be in all Functions but is only needed in # some Classes pass def disable_keybinding(self): # this function has to be in all Functions but is only needed in # some Classes pass def change_skipped_frame(self,value): value = int(value) system_code.skipable_frames = value self.skip_slider_value.configure(text=value) def change_thickness(self, value): value = int(value) system_code.thickness = value self.thickness_slider_value.configure(text=value) def ask_color(self): self.pick_color = AskColor(master=self.master, font=self.my_font) self.wait_window(self.pick_color) self.color = self.pick_color.get() # get the color string if self.color is not None: self.color_btn.configure(fg_color=self.color) system_code.color = self.color # set the wanted image format def set_img_format(self, value): system_code.img_format = value def change_thread_type(self, value): if value == "manual": self.show_thread_selection() system_code.thread_detection_mode = "manual" self.thread_count_switch.set(system_code.used_threads) else: system_code.thread_detection_mode = "automatic" system_code.calculate_automatic_threads() if self.thread_count_switch is not None: self.thread_count_switch.place_forget() def show_thread_selection(self): self.thread_count_switch.place( relx=0.9, rely=0.8, anchor="e", relwidth=0.5, relheight=0.06 ) def change_manual_threads(self, value): system_code.used_threads = value self.thread_count_switch.set(value) def align(self): self.color_information.place( relx=0.10, rely=0.3, anchor="w", relwidth=0.3, relheight=0.06 ) self.color_btn.place( relx=0.9, rely=0.3, anchor="e", relwidth=0.5, relheight=0.06 ) self.thickness_label.place( relx=0.10, rely=0.4, anchor="w", relwidth=0.3, relheight=0.06 ) # Position the converter button to the left self.thickness_slider.place( relx=0.6, rely=0.4, anchor="center", relwidth=0.4, relheight=0.03 ) # Position the converter button to the left self.thickness_slider_value.place( relx=0.9, rely=0.4, anchor="e", relwidth=0.05, relheight=0.06 ) # Position the converter button to the left self.skip_label.place( relx=0.10, rely=0.5, anchor="w", relwidth=0.3, relheight=0.06 ) # Position the converter button to the left self.skip_slider.place( relx=0.6, rely=0.5, anchor="center", relwidth=0.4, relheight=0.03 ) # Position the converter button to the left self.skip_slider_value.place( relx=0.9, rely=0.5, anchor="e", relwidth=0.05, relheight=0.06 ) # Position the converter button to the left self.label_output_formats.place( relx=0.10, rely=0.6, anchor="w", relwidth=0.3, relheight=0.06 ) self.output_formats.place( relx=0.9, rely=0.6, anchor="e", relwidth=0.5, relheight=0.06 ) self.label_threads.place( relx=0.1, rely=0.7, anchor="w", relwidth=0.3, relheight=0.06 ) self.thread_switch.place( relx=0.9, rely=0.7, anchor="e", relwidth=0.5, relheight=0.06 )