def __init__(self, main_gui, scale_factor=1): super().__init__() self.wm_title("Advanced Settings") self.main_gui = main_gui self.scale_factor = scale_factor # sets the icon self.__imgicon__ = PhotoImage(file=os.path.join(CURRENT_PATH + "media", "manual.png")) self.tk.call('wm', 'iconphoto', self._w, self.__imgicon__) self.remove_credentials_button = Button(self, text='Reset credentials', command=self.remove_cred) self.remove_credentials_button.pack(pady=10) self.__init_scale_factor_frame__() self.__init_nm_frame__() self.save_button = Button(self, text="Save", command=self.save_current_settings, height=6) self.save_button.pack(ipady=10, pady=10) # retrieving existing default configuration if(advanced_settings_are_correct()): (scale_factor, nm_use) = advanced_settings_read() self.set_scale(scale_factor) self.set_nm_use(nm_use) else: advanced_settings_save(DEFAULT_SCALE_FACTOR, DEFAULT_NM_USE) self.set_scale(DEFAULT_SCALE_FACTOR) self.set_nm_use(DEFAULT_NM_USE) self.center_window(300 * scale_factor, 150 * scale_factor) self.grab_set() # used to disable the underlying window
def save_current_settings(self): advanced_settings_save(self.get_scale(), self.get_nm_use()) self.main_gui.update_advanced_settings(self.get_nm_use()) messagebox.showinfo(parent=self, title="Restart required", message='Restart the application to apply scale')