def delete_zoom(self): '''Delete the amount of zoomed from the json file''' font_details = include.get_font_details() if 'Zoomed' in font_details: font_details.pop('Zoomed') include.save_font_details(font_details)
def save_zoomed(self, zoomed=None): '''Save the amount of zoom in and zoom out to the json file''' font_details = include.get_font_details() if zoomed is None: # This means remove zoomed amount self.zoomed = 0 if 'Zoomed' in font_details: font_details.pop('Zoomed') self.font.configure(family=font_details['Font Family'], size=font_details['Font Size']) else: font_details['Zoomed'] = self.zoomed include.save_font_details(font_details)
def cmd(self, event=None): '''Set font_family, font_size and font_style to the text-widget and save them to the file so that same font details are used when the program runs next time.''' font_family = self.font_families_frame.entry_var.get().strip() font_style = self.font_style_frame.entry_var.get().strip().lower() font_size = self.font_size_frame.entry_var.get().strip() if font_family.lower() not in self.lower_font_name: messagebox.showinfo('Font', 'There is no font with that name.\nChoose a font from the list of fonts.', parent=self.top_level) return elif font_style not in self.lower_font_style: messagebox.showinfo('Font', 'This font is not available in that style.\nChoose a style from the list of styles.', parent=self.top_level) return if not font_size.isdigit(): font_size = 9 if font_size.isdigit() and isinstance(font_size, str): font_size = int(font_size) if font_style == 'regular': font_style = 'normal' include.config_font_style(font_style, self.font) font_details = include.get_font_details() if 'Zoomed' in font_details: self.font.configure(family=font_family, size=font_size + font_details['Zoomed']) else: self.font.configure(family=font_family, size=font_size) font_index = self.lower_font_name.index(font_family.lower()) # Getting index of the font_family in entry_widget font_details['Font Family'] = self.font_families[font_index] font_details['Font Size'] = font_size font_details['Font Style'] = font_style include.save_font_details(font_details) # Saving font_details in file self.top_level.destroy()